mapping

package
v1.0.22-0...-5969f35 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedType is an error that indicates the config format is not supported.
	ErrUnsupportedType = errors.New("only map-like configs are suported")
)

Functions

func Deref

func Deref(t reflect.Type) reflect.Type

Deref dereferences a type, if pointer type, returns its element type.

func Repr

func Repr(v interface{}) string

Repr returns the string representation of v.

func UnmarshalJsonBytes

func UnmarshalJsonBytes(content []byte, v interface{}) error

UnmarshalJsonBytes unmarshals content into v.

func UnmarshalJsonReader

func UnmarshalJsonReader(reader io.Reader, v interface{}) error

UnmarshalJsonReader unmarshals content from reader into v.

func UnmarshalKey

func UnmarshalKey(m map[string]interface{}, v interface{}) error

UnmarshalKey unmarshals m into v with tag key.

func UnmarshalYamlBytes

func UnmarshalYamlBytes(content []byte, v interface{}) error

UnmarshalYamlBytes unmarshals content into v.

func UnmarshalYamlReader

func UnmarshalYamlReader(reader io.Reader, v interface{}) error

UnmarshalYamlReader unmarshals content from reader into v.

func ValidatePtr

func ValidatePtr(v *reflect.Value) error

ValidatePtr validates v if it's a valid pointer.

Types

type MapValuer

type MapValuer map[string]interface{}

A MapValuer is a map that can use Value method to get values with given keys.

func (MapValuer) Value

func (mv MapValuer) Value(key string) (interface{}, bool)

Value gets the value associated with the given key from mv.

type UnmarshalOption

type UnmarshalOption func(*unmarshalOptions)

UnmarshalOption defines the method to customize a Unmarshaler.

func WithStringValues

func WithStringValues() UnmarshalOption

WithStringValues customizes a Unmarshaler with number values from strings.

type Unmarshaler

type Unmarshaler struct {
	// contains filtered or unexported fields
}

A Unmarshaler is used to unmarshal with given tag key.

func NewUnmarshaler

func NewUnmarshaler(key string, opts ...UnmarshalOption) *Unmarshaler

NewUnmarshaler returns a Unmarshaler.

func (*Unmarshaler) Unmarshal

func (u *Unmarshaler) Unmarshal(m map[string]interface{}, v interface{}) error

Unmarshal unmarshals m into v.

func (*Unmarshaler) UnmarshalValuer

func (u *Unmarshaler) UnmarshalValuer(m Valuer, v interface{}) error

UnmarshalValuer unmarshals m into v.

type Valuer

type Valuer interface {
	// Value gets the value associated with the given key.
	Value(key string) (interface{}, bool)
}

A Valuer interface defines the way to get values from the underlying object with keys.

Jump to

Keyboard shortcuts

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