Documentation ¶
Index ¶
- Constants
- Variables
- func IsContainer(v reflect.Value) bool
- func IsEmpty(v reflect.Value) bool
- func Map(v, s interface{}) error
- func StringifyKeys(val interface{}) interface{}
- func TypeClass(kind reflect.Kind) int
- func TypeCompatibility(from, to reflect.Type) int
- func UnwrapAny(v reflect.Value) reflect.Value
- func UnwrapInterface(v reflect.Value) reflect.Value
- func UnwrapPtr(v reflect.Value) reflect.Value
- type AutoDecoder
- type Decoder
- type FieldInfo
- type JSONDecoder
- type Loader
- type MapTracer
- type Mapper
- type TypeConverter
- type YAMLDecoder
Constants ¶
const ( InvalidClass int = iota BoolClass IntClass UintClass FloatClass ComplexClass SliceClass ChanClass FuncClass InterfaceClass MapClass PtrClass StringClass StructClass UnsafePointerClass )
Compatible type classes
const ( Assignable int = iota Convertible Incompatible )
Assignability
Variables ¶
var ( // StringType defined and used as a const StringType = reflect.TypeOf("") // InterfaceType defined and used as a const InterfaceType = reflect.TypeOf([]interface{}{}).Elem() )
Functions ¶
func IsContainer ¶
IsContainer determine if the value is map or struct
func StringifyKeys ¶
func StringifyKeys(val interface{}) interface{}
StringifyKeys converts keys to strings
func TypeCompatibility ¶
TypeCompatibility determines the assignment/conversion compatibility
func UnwrapInterface ¶
UnwrapInterface returns the actual value of the interface
Types ¶
type AutoDecoder ¶
type AutoDecoder struct { }
AutoDecoder selects the correct decoder by detecting the content
func (*AutoDecoder) Decode ¶
func (d *AutoDecoder) Decode(content []byte) (out interface{}, err error)
Decode implements Decoder
type FieldInfo ¶
type FieldInfo struct { Exported bool Squash bool OmitEmpty bool Wildcard bool Ignore bool MapName string }
FieldInfo contains parsed information from struct field
type JSONDecoder ¶
type JSONDecoder struct { }
JSONDecoder decodes content in JSON
func (*JSONDecoder) Decode ¶
func (d *JSONDecoder) Decode(content []byte) (out interface{}, err error)
Decode implements Decoder
type Loader ¶
Loader loads and parses map from file/string
func (*Loader) LoadStream ¶
LoadStream loads from a stream
func (*Loader) LoadString ¶
LoadString decodes the content in string
type Mapper ¶
Mapper assign dynamic values
func (*Mapper) MapValue ¶
MapValue copies values of reflect.Value If the destination is a pointer, the address is assigned
func (*Mapper) ParseField ¶
func (m *Mapper) ParseField(f reflect.StructField) *FieldInfo
ParseField extracts useful information from struct field
type TypeConverter ¶
TypeConverter defines the function to convert values IsValid is false if not convertible
func TypeConverterFactory ¶
func TypeConverterFactory(from, to reflect.Type) TypeConverter
TypeConverterFactory creates the converter by types
type YAMLDecoder ¶
type YAMLDecoder struct { }
YAMLDecoder decodes content in YAML
func (*YAMLDecoder) Decode ¶
func (d *YAMLDecoder) Decode(content []byte) (out interface{}, err error)
Decode implements Decoder