Documentation
¶
Index ¶
- Constants
- Variables
- func CopyDefaults(a, b interface{})
- func CopyFrom(a, b interface{})
- func FieldName(name string) string
- func FlattenMap(a map[string]interface{}) map[string]interface{}
- func IsEmpty(v reflect.Value) bool
- func IsZero(src interface{}) bool
- func Lookup(i interface{}, path string) (reflect.Value, error)
- func Merge(dst interface{}, mp map[string]interface{}, opts ...Option) error
- func SetFieldByPath(src interface{}, dst interface{}, path string) error
- func StructFieldByName(src interface{}, tkey string) (interface{}, error)
- func StructFieldByPath(src interface{}, path string) (interface{}, error)
- func StructFieldByTag(src interface{}, tkey string, tval string) (interface{}, error)
- func StructFieldsMap(src interface{}) (map[string]interface{}, error)
- func StructURLValues(src interface{}, pref string, tags []string) (url.Values, error)
- func URLMap(query string) (map[string]interface{}, error)
- func Zero(src interface{}) (interface{}, error)
- func ZeroFieldByPath(src interface{}, path string) error
- type Option
- type Options
- type StructField
Constants ¶
const ( SplitToken = "." IndexCloseChar = "]" IndexOpenChar = "[" )
Variables ¶
var ( ErrMalformedIndex = errors.New("Malformed index key") ErrInvalidIndexUsage = errors.New("Invalid index key usage") ErrKeyNotFound = errors.New("Unable to find the key") ErrBadJSONPath = errors.New("Bad path: must start with $ and have more then 2 chars") )
var ( ErrInvalidStruct = errors.New("invalid struct specified") ErrInvalidValue = errors.New("invalid value specified") ErrNotFound = errors.New("struct field not found") )
var ErrInvalidParam = errors.New("invalid url query param provided")
ErrInvalidParam specifies invalid url query params
Functions ¶
func CopyDefaults ¶
func CopyDefaults(a, b interface{})
CopyDefaults for a from b a and b should be pointers to the same kind of struct
func CopyFrom ¶
func CopyFrom(a, b interface{})
CopyFrom sets the public members of a from b a and b should be pointers to structs a can be a different type from b Only the Fields which have the same name and assignable type on a and b will be set.
func FlattenMap ¶
FlattenMap expand key.subkey to nested map
func IsZero ¶
func IsZero(src interface{}) bool
IsZero returns true if struct is zero (not have any defined values)
func SetFieldByPath ¶ added in v3.8.5
SetFieldByPath set struct field by its path
func StructFieldByName ¶
StructFieldByName get struct field by its name
func StructFieldByPath ¶
StructFieldByPath get struct field by its path
func StructFieldByTag ¶
StructFieldByTag get struct field by tag key and its value
func StructFieldsMap ¶
StructFieldsMap returns struct map[string]interface{} or error
func StructURLValues ¶
StructURLValues get struct fields via url.Values
func ZeroFieldByPath ¶ added in v3.8.4
ZeroFieldByPath clean struct field by its path
Types ¶
type StructField ¶
type StructField struct { Path string Value reflect.Value Field reflect.StructField }
StructField contains struct field path its value and field
func StructFields ¶
func StructFields(src interface{}) ([]StructField, error)
StructFields returns slice of struct fields