Documentation ¶
Index ¶
- func Marshal(rawVal any) (map[string]any, error)
- func MarshalerHookFunc(orig any) mapstructure.DecodeHookFuncValue
- func NilHookFunc[T any]() mapstructure.DecodeHookFuncValue
- func NilZeroValueHookFunc[T any]() mapstructure.DecodeHookFuncValue
- func TextMarshalerHookFunc() mapstructure.DecodeHookFuncValue
- func UnsupportedKindHookFunc() mapstructure.DecodeHookFuncValue
- type Encoder
- type EncoderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalerHookFunc ¶
func MarshalerHookFunc(orig any) mapstructure.DecodeHookFuncValue
MarshalerHookFunc returns a DecodeHookFuncValue that checks structs that aren't the original to see if they implement the Marshaler interface.
func NilHookFunc ¶
func NilHookFunc[T any]() mapstructure.DecodeHookFuncValue
NilHookFunc returns a DecodeHookFuncValue that checks if the value matches the type and nils it out. Allows specific types to be omitted.
func NilZeroValueHookFunc ¶
func NilZeroValueHookFunc[T any]() mapstructure.DecodeHookFuncValue
NilZeroValueHookFunc returns a DecodeHookFuncValue that only nils the field if it's a zero value.
func TextMarshalerHookFunc ¶
func TextMarshalerHookFunc() mapstructure.DecodeHookFuncValue
TextMarshalerHookFunc returns a DecodeHookFuncValue that checks for the encoding.TextMarshaler interface and calls the MarshalText function if found.
func UnsupportedKindHookFunc ¶
func UnsupportedKindHookFunc() mapstructure.DecodeHookFuncValue
UnsupportedKindHookFunc returns a DecodeHookFuncValue that checks that the kind isn't one unsupported by the YAML encoder.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder takes structured data and converts it into an interface following the mapstructure tags.
type EncoderConfig ¶
type EncoderConfig struct { // EncodeHook, if set, is a way to provide custom encoding. It // will be called before structs and primitive types. EncodeHook mapstructure.DecodeHookFunc // NilEmptyMap, if set, is a way to nil out empty maps. NilEmptyMap bool // OmitNilFields, if set, is a way to omit all nil struct fields even if omitempty isn't present. OmitNilFields bool }
EncoderConfig is the configuration used to create a new encoder.