storage

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load added in v0.0.4

func Load(p Parser, reader io.Reader) (interface{}, error)

Load loads data from the given io.Reader.

func LoadFromFile

func LoadFromFile(filename string, p Parser) (interface{}, error)

LoadFromFile loads data from the given file.

func Write added in v0.0.4

func Write(p Parser, value interface{}, writer io.Writer) error

Write writes the value to the given io.Writer.

Types

type JSONParser

type JSONParser struct {
}

JSONParser is a Parser implementation to handle yaml files.

func (*JSONParser) FromBytes

func (p *JSONParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some Data that is represented by the given bytes.

func (*JSONParser) ToBytes

func (p *JSONParser) ToBytes(value interface{}) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type Parser

type Parser interface {
	// FromBytes returns some Data that is represented by the given bytes.
	FromBytes(byteData []byte) (interface{}, error)
	// ToBytes returns a slice of bytes that represents the given value.
	ToBytes(value interface{}) ([]byte, error)
}

Parser can be used to load and save files from/to disk.

func NewParserFromFilename

func NewParserFromFilename(filename string) (Parser, error)

NewParserFromFilename returns a Parser from the given filename.

func NewParserFromString

func NewParserFromString(parser string) (Parser, error)

NewParserFromString returns a Parser from the given parser name.

type TOMLParser added in v0.0.5

type TOMLParser struct {
}

TOMLParser is a Parser implementation to handle yaml files.

func (*TOMLParser) FromBytes added in v0.0.5

func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some Data that is represented by the given bytes.

func (*TOMLParser) ToBytes added in v0.0.5

func (p *TOMLParser) ToBytes(value interface{}) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type UnknownParserErr

type UnknownParserErr struct {
	Parser string
}

UnknownParserErr is returned when an invalid parser name is given.

func (UnknownParserErr) Error

func (e UnknownParserErr) Error() string

Error returns the error message.

type XMLParser added in v1.0.1

type XMLParser struct {
}

XMLParser is a Parser implementation to handle yaml files.

func (*XMLParser) FromBytes added in v1.0.1

func (p *XMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some Data that is represented by the given bytes.

func (*XMLParser) ToBytes added in v1.0.1

func (p *XMLParser) ToBytes(value interface{}) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

type YAMLParser

type YAMLParser struct {
}

YAMLParser is a Parser implementation to handle yaml files.

func (*YAMLParser) FromBytes

func (p *YAMLParser) FromBytes(byteData []byte) (interface{}, error)

FromBytes returns some Data that is represented by the given bytes.

func (*YAMLParser) ToBytes

func (p *YAMLParser) ToBytes(value interface{}) ([]byte, error)

ToBytes returns a slice of bytes that represents the given value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL