Documentation ¶
Index ¶
- Variables
- func Deref(t reflect.Type) reflect.Type
- func Marshal(val interface{}) (map[string]map[string]interface{}, error)
- func Repr(v interface{}) string
- func UnmarshalJsonBytes(content []byte, v interface{}) error
- func UnmarshalJsonMap(m map[string]interface{}, v interface{}) error
- func UnmarshalJsonReader(reader io.Reader, v interface{}) error
- func UnmarshalKey(m map[string]interface{}, v interface{}) error
- func UnmarshalTomlBytes(content []byte, v interface{}) error
- func UnmarshalTomlReader(r io.Reader, v interface{}) error
- func UnmarshalYamlBytes(content []byte, v interface{}) error
- func UnmarshalYamlReader(reader io.Reader, v interface{}) error
- func ValidatePtr(v *reflect.Value) error
- type MapValuer
- type UnmarshalOption
- type Unmarshaler
- type Valuer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedType is an error that indicates the config format is not supported. ErrUnsupportedType = errors.New("only map-like configs are supported") )
Functions ¶
func Marshal ¶
Marshal marshals the given val and returns the map that contains the fields. optional=another is not implemented, and it's hard to implement and not common used.
func UnmarshalJsonBytes ¶
UnmarshalJsonBytes unmarshals content into v.
func UnmarshalJsonMap ¶
UnmarshalJsonMap unmarshals content from m into v.
func UnmarshalJsonReader ¶
UnmarshalJsonReader unmarshals content from reader into v.
func UnmarshalKey ¶
UnmarshalKey unmarshals m into v with tag key.
func UnmarshalTomlBytes ¶
UnmarshalTomlBytes unmarshals TOML bytes into the given v.
func UnmarshalTomlReader ¶
UnmarshalTomlReader unmarshals TOML from the given io.Reader into the given v.
func UnmarshalYamlBytes ¶
UnmarshalYamlBytes unmarshals content into v.
func UnmarshalYamlReader ¶
UnmarshalYamlReader unmarshals content from reader into v.
func ValidatePtr ¶
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.
type UnmarshalOption ¶
type UnmarshalOption func(*unmarshalOptions)
UnmarshalOption defines the method to customize a Unmarshaler.
func WithCanonicalKeyFunc ¶
func WithCanonicalKeyFunc(f func(string) string) UnmarshalOption
WithCanonicalKeyFunc customizes a Unmarshaler with Canonical Key func
func WithStringValues ¶
func WithStringValues() UnmarshalOption
WithStringValues customizes a Unmarshaler with number values from strings.
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 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.