mapstructure

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TextMarshalerHookFunc

func TextMarshalerHookFunc() mapstructure.DecodeHookFuncValue

TextMarshalerHookFunc returns a DecodeHookFuncValue that checks for the encoding.TextMarshaler interface and calls the MarshalText function if found.

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.

func New

func New(cfg *EncoderConfig) *Encoder

New returns a new encoder for the configuration.

func (*Encoder) Encode

func (e *Encoder) Encode(input any) (any, error)

Encode takes the input and uses reflection to encode it to an interface based on the mapstructure spec.

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
}

EncoderConfig is the configuration used to create a new encoder.

Jump to

Keyboard shortcuts

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