Documentation ¶
Index ¶
- func Decode(input interface{}, output interface{}) error
- func DecodeHookExec(raw DecodeHookFunc, from reflect.Value, to reflect.Value) (interface{}, error)
- func DecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error
- func Marshal(v interface{}) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- func WeakDecode(input, output interface{}) error
- func WeakDecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error
- func WeaklyTypedHook(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error)
- type DecodeHookFunc
- func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc
- func RecursiveStructToMapHookFunc() DecodeHookFunc
- func StringToIPHookFunc() DecodeHookFunc
- func StringToIPNetHookFunc() DecodeHookFunc
- func StringToSliceHookFunc(sep string) DecodeHookFunc
- func StringToTimeDurationHookFunc() DecodeHookFunc
- func StringToTimeHookFunc(layout string) DecodeHookFunc
- type DecodeHookFuncKind
- type DecodeHookFuncType
- type DecodeHookFuncValue
- type Decoder
- type DecoderConfig
- type Error
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeHookExec ¶
DecodeHookExec executes the given decode hook. This should be used since it'll naturally degrade to the older backwards compatible DecodeHookFunc that took reflect.Kind instead of reflect.Type.
func DecodeMetadata ¶
func WeakDecode ¶
func WeakDecode(input, output interface{}) error
func WeakDecodeMetadata ¶
WeakDecodeMetadata is the same as Decode, but is shorthand to enable both WeaklyTypedInput and metadata collection. See DecoderConfig for more info.
Types ¶
type DecodeHookFunc ¶
type DecodeHookFunc interface{}
func ComposeDecodeHookFunc ¶
func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc
ComposeDecodeHookFunc creates a single DecodeHookFunc that automatically composes multiple DecodeHookFuncs.
The composed funcs are called in order, with the result of the previous transformation.
func RecursiveStructToMapHookFunc ¶
func RecursiveStructToMapHookFunc() DecodeHookFunc
func StringToIPHookFunc ¶
func StringToIPHookFunc() DecodeHookFunc
StringToIPHookFunc returns a DecodeHookFunc that converts strings to net.IP
func StringToIPNetHookFunc ¶
func StringToIPNetHookFunc() DecodeHookFunc
StringToIPNetHookFunc returns a DecodeHookFunc that converts strings to net.IPNet
func StringToSliceHookFunc ¶
func StringToSliceHookFunc(sep string) DecodeHookFunc
StringToSliceHookFunc returns a DecodeHookFunc that converts string to []string by splitting on the given sep.
func StringToTimeDurationHookFunc ¶
func StringToTimeDurationHookFunc() DecodeHookFunc
StringToTimeDurationHookFunc returns a DecodeHookFunc that converts strings to time.Duration.
func StringToTimeHookFunc ¶
func StringToTimeHookFunc(layout string) DecodeHookFunc
StringToTimeHookFunc returns a DecodeHookFunc that converts strings to time.Time.
type DecodeHookFuncKind ¶
type DecodeHookFuncType ¶
func TextUnmarshallerHookFunc ¶
func TextUnmarshallerHookFunc() DecodeHookFuncType
TextUnmarshallerHookFunc returns a DecodeHookFunc that applies strings to the UnmarshalText function, when the target type implements the encoding.TextUnmarshaler interface
type DecodeHookFuncValue ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder(config *DecoderConfig) (*Decoder, error)
NewDecoder returns a new decoder for the given configuration. Once a decoder has been returned, the same configuration must not be used again.
type DecoderConfig ¶
type Error ¶
type Error struct {
Errors []string
}
Error implements the error interface and can represents multiple errors that occur in the course of a single decode.
func (*Error) WrappedErrors ¶
WrappedErrors implements the errwrap.Wrapper interface to make this return value more useful with the errwrap and go-multierror libraries.