Documentation ¶
Index ¶
Constants ¶
const ( // JSON is a JSON format name. JSON = "json" // YAML is a YAML format name. YAML = "yaml" // TOML is a TOML format name. TOML = "toml" // HEX is a HEX format name. HEX = "hex" )
Variables ¶
Functions ¶
func NewErrFormatNameIsEmpty ¶
func NewErrFormatNameIsEmpty() error
NewErrFormatNameIsEmpty wraps format name with ErrFormatNameIsEmpty.
func NewErrNotSupported ¶
NewErrNotSupported wraps format name with ErrNotSupported.
Types ¶
type ErrFormatNameIsEmpty ¶
type ErrFormatNameIsEmpty struct{}
ErrFormatNameIsEmpty indicates that format name is an empty string.
func (*ErrFormatNameIsEmpty) Error ¶
func (e *ErrFormatNameIsEmpty) Error() string
type ErrNotSupported ¶
type ErrNotSupported struct {
Format string
}
ErrNotSupported indicates that format with specified name is not supported.
func (*ErrNotSupported) Error ¶
func (e *ErrNotSupported) Error() string
type Format ¶
type Format interface { Marshal(v interface{}) ([]byte, error) Unmarshal(data []byte, v interface{}) error Name() string }
Format is a iterator that provides a data from source.
func NewFromPath ¶
NewFromPath returns a new Format from file extension in the path argument. It respects the synonyms for format names, for example: yaml format files could have extensions yaml or yml.
type HEXFormat ¶
type HEXFormat struct{}
HEXFormat is a HEX marshaler.
type JSONFormat ¶
type JSONFormat struct{}
JSONFormat is a JSON marshaler.
func (*JSONFormat) Marshal ¶
func (j *JSONFormat) Marshal(v interface{}) ([]byte, error)
Marshal serializes data represented by v into slice of bytes.
func (*JSONFormat) Name ¶
func (j *JSONFormat) Name() string
Name returns a format name which is used to identify this format in the package.
func (*JSONFormat) Unmarshal ¶
func (j *JSONFormat) Unmarshal(data []byte, v interface{}) error
Unmarshal deserializes data represented by data byte slice into v.
type TOMLFormat ¶
type TOMLFormat struct{}
TOMLFormat is a TOML marshaler.
func (*TOMLFormat) Marshal ¶
func (y *TOMLFormat) Marshal(v interface{}) ([]byte, error)
Marshal serializes data represented by v into slice of bytes.
func (*TOMLFormat) Name ¶
func (y *TOMLFormat) Name() string
Name returns a format name which is used to identify this format in the package.
func (*TOMLFormat) Unmarshal ¶
func (y *TOMLFormat) Unmarshal(data []byte, v interface{}) error
Unmarshal deserializes data represented by data byte slice into v.
type YAMLFormat ¶
type YAMLFormat struct{}
YAMLFormat is a YAML marshaler.
func (*YAMLFormat) Marshal ¶
func (y *YAMLFormat) Marshal(v interface{}) ([]byte, error)
Marshal serializes data represented by v into slice of bytes.
func (*YAMLFormat) Name ¶
func (y *YAMLFormat) Name() string
Name returns a format name which is used to identify this format in the package.
func (*YAMLFormat) Unmarshal ¶
func (y *YAMLFormat) Unmarshal(data []byte, v interface{}) error
Unmarshal deserializes data represented by data byte slice into v.