Documentation
¶
Index ¶
- Variables
- func Any(value interface{}) *any
- func Bool(any interface{}) bool
- func Byte(any interface{}) byte
- func Bytes(any interface{}) []byte
- func Duration(any interface{}) time.Duration
- func Float32(any interface{}) float32
- func Float64(any interface{}) float64
- func FormEncode(params map[string]interface{}) url.Values
- func Int(any interface{}) int
- func Int16(any interface{}) int16
- func Int32(any interface{}) int32
- func Int32s(any interface{}) []int32
- func Int64(any interface{}) int64
- func Int64s(any interface{}) []int64
- func Int8(any interface{}) int8
- func Interfaces(any interface{}) []interface{}
- func Ints(any interface{}) []int
- func Map(value interface{}, tags ...string) map[string]interface{}
- func ParseDuration(s string) (duration time.Duration, err error)
- func Rune(any interface{}) rune
- func Runes(any interface{}) []rune
- func SliceAny(any interface{}) []interface{}
- func SliceInt(any interface{}) []int
- func SliceInt32(any interface{}) []int32
- func SliceInt64(any interface{}) []int64
- func SliceStr(any interface{}) []string
- func String(any interface{}) string
- func Strings(any interface{}) []string
- func StructMap(value interface{}, option ...MapOption) map[string]interface{}
- func Time(any interface{}, format ...string) time.Time
- func Uint(any interface{}) uint
- func Uint16(any interface{}) uint16
- func Uint32(any interface{}) uint32
- func Uint64(any interface{}) uint64
- func Uint8(any interface{}) uint8
- type MapOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // StructTagPriority defines the default priority tags for Map*/Struct* functions. // Note that, the `gconv/param` tags are used by old version of package. // It is strongly recommended using short tag `c/p` instead in the future. StructTagPriority = tag.StructTagPriority )
Functions ¶
func Bool ¶
func Bool(any interface{}) bool
Bool converts `any` to bool. It returns false if `any` is: false, "", 0, "false", "off", "no", empty slice/map.
func FormEncode ¶ added in v0.0.4
func Interfaces ¶
func Interfaces(any interface{}) []interface{}
Interfaces converts `any` to []interface{}.
func ParseDuration ¶ added in v0.0.7
func StructMap ¶ added in v0.0.3
Map converts any variable `value` to map[string]interface{}. If the parameter `value` is not a map/struct/*struct type, then the conversion will fail and returns nil.
If `value` is a struct/*struct object, the second parameter `tags` specifies the most priority tags that will be detected, otherwise it detects the tags in order of: gconv, json, field name.
Types ¶
type MapOption ¶ added in v0.0.3
type MapOption struct {
// Deep marks doing Map function recursively, which means if the attribute of given converting value
// is also a struct/*struct, it automatically calls Map function on this attribute converting it to
// a map[string]interface{} type variable.
Deep bool
// OmitEmpty ignores the attributes that has json `omitempty` tag.
OmitEmpty bool
// Tags specifies the converted map key name by struct tag name.
Tags []string
}
MapOption specifies the option for map converting.
Click to show internal directories.
Click to hide internal directories.