Documentation ¶
Index ¶
Constants ¶
const ( // ErrDecoderNotFound is returned when there is no decoder registered for a format. ErrDecoderNotFound = encodingError("decoder not found for this format") // ErrDecoderFormatAlreadyRegistered is returned when an decoder is already registered for a format. ErrDecoderFormatAlreadyRegistered = encodingError("decoder already registered for this format") )
const ( // ErrEncoderNotFound is returned when there is no encoder registered for a format. ErrEncoderNotFound = encodingError("encoder not found for this format") // ErrEncoderFormatAlreadyRegistered is returned when an encoder is already registered for a format. ErrEncoderFormatAlreadyRegistered = encodingError("encoder already registered for this format") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
Decoder decodes the contents of b into v. It's primarily used for decoding contents of a file into a map[string]interface{}.
type DecoderRegistry ¶
type DecoderRegistry struct {
// contains filtered or unexported fields
}
DecoderRegistry can choose an appropriate Decoder based on the provided format.
func NewDecoderRegistry ¶
func NewDecoderRegistry() *DecoderRegistry
NewDecoderRegistry returns a new, initialized DecoderRegistry.
func (*DecoderRegistry) Decode ¶
func (e *DecoderRegistry) Decode(format string, b []byte, v map[string]interface{}) error
Decode calls the underlying Decoder based on the format.
func (*DecoderRegistry) RegisterDecoder ¶
func (e *DecoderRegistry) RegisterDecoder(format string, enc Decoder) error
RegisterDecoder registers a Decoder for a format. Registering a Decoder for an already existing format is not supported.
type Encoder ¶
Encoder encodes the contents of v into a byte representation. It's primarily used for encoding a map[string]interface{} into a file format.
type EncoderRegistry ¶
type EncoderRegistry struct {
// contains filtered or unexported fields
}
EncoderRegistry can choose an appropriate Encoder based on the provided format.
func NewEncoderRegistry ¶
func NewEncoderRegistry() *EncoderRegistry
NewEncoderRegistry returns a new, initialized EncoderRegistry.
func (*EncoderRegistry) Encode ¶
func (e *EncoderRegistry) Encode(format string, v map[string]interface{}) ([]byte, error)
func (*EncoderRegistry) RegisterEncoder ¶
func (e *EncoderRegistry) RegisterEncoder(format string, enc Encoder) error
RegisterEncoder registers an Encoder for a format. Registering a Encoder for an already existing format is not supported.