mapping

package
v0.0.0-...-98563ba Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(list []string, str string) bool

Contains checks if str is in list.

func Deref

func Deref(t reflect.Type) reflect.Type

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

func SetMapIndexValue

func SetMapIndexValue(tp reflect.Type, value, key, target reflect.Value)

SetMapIndexValue sets target to value at key position, pointers are processed automatically.

func SetValue

func SetValue(tp reflect.Type, value, target reflect.Value)

SetValue sets target to value, pointers are processed automatically.

func TakeOne

func TakeOne(valid, or string) string

TakeOne returns valid string if not empty or later one.

func UnmarshalJsonMap

func UnmarshalJsonMap(m map[string]any, v any, opts ...UnmarshalOption) error

UnmarshalJsonMap unmarshals content from m into v.

func ValidatePtr

func ValidatePtr(v *reflect.Value) error

ValidatePtr validates v if it's a valid pointer.

Types

type UnmarshalOption

type UnmarshalOption func(*unmarshalOptions)

UnmarshalOption defines the method to customize an Unmarshaler.

func WithCanonicalKeyFunc

func WithCanonicalKeyFunc(f func(string) string) UnmarshalOption

WithCanonicalKeyFunc customizes an Unmarshaler with Canonical Key func.

type Unmarshaler

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

Unmarshaler is used to unmarshal with given tag key.

func NewUnmarshaler

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

NewUnmarshaler returns an Unmarshaler.

func (*Unmarshaler) Unmarshal

func (u *Unmarshaler) Unmarshal(i any, v any) error

Unmarshal unmarshals m into v.

func (*Unmarshaler) UnmarshalValuer

func (u *Unmarshaler) UnmarshalValuer(m Valuer, v any) error

UnmarshalValuer unmarshals m into v.

type Valuer

type Valuer interface {
	// Value gets the value associated with the given key.
	Value(key string) (any, 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