Documentation
¶
Index ¶
- Variables
- func Bool(i interface{}) bool
- func BoolSlice(i interface{}) []bool
- func Byte(any interface{}) byte
- func Bytes(any interface{}) []byte
- func Duration(i interface{}) time.Duration
- func DurationSlice(i interface{}) []time.Duration
- func Float32(i interface{}) float32
- func Float64(i interface{}) float64
- func Int(i interface{}) int
- func Int16(i interface{}) int16
- func Int32(i interface{}) int32
- func Int32ToString(i int32) string
- func Int32s(any interface{}) []int32
- func Int64(i interface{}) int64
- func Int64s(any interface{}) []int64
- func Int8(i interface{}) int8
- func IntSlice(i interface{}) []int
- func IntToString(i int) string
- func Interfaces(any interface{}) []interface{}
- func Ints(any interface{}) []int
- func Map(value interface{}, tags ...string) map[string]interface{}
- func MapStrStr(value interface{}, tags ...string) map[string]string
- func Rune(any interface{}) rune
- func Slice(i interface{}) []interface{}
- 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(i interface{}) string
- func StringMap(i interface{}) map[string]interface{}
- func StringMapBool(i interface{}) map[string]bool
- func StringMapInt(i interface{}) map[string]int
- func StringMapInt64(i interface{}) map[string]int64
- func StringMapString(i interface{}) map[string]string
- func StringMapStringSlice(i interface{}) map[string][]string
- func StringSlice(i interface{}) []string
- func StringToDate(s string) (time.Time, error)
- func StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error)
- func Strings(any interface{}) []string
- func Time(i interface{}) time.Time
- func TimeInDefaultLocation(i interface{}, location *time.Location) time.Time
- func ToBoolE(i interface{}) (bool, error)
- func ToBoolSliceE(i interface{}) ([]bool, error)
- func ToDurationE(i interface{}) (d time.Duration, err error)
- func ToDurationSliceE(i interface{}) ([]time.Duration, error)
- func ToFloat32E(i interface{}) (float32, error)
- func ToFloat64E(i interface{}) (float64, error)
- func ToInt16E(i interface{}) (int16, error)
- func ToInt32E(i interface{}) (int32, error)
- func ToInt64E(i interface{}) (int64, error)
- func ToInt8E(i interface{}) (int8, error)
- func ToIntE(i interface{}) (int, error)
- func ToIntSliceE(i interface{}) ([]int, error)
- func ToSliceE(i interface{}) ([]interface{}, error)
- func ToStringE(i interface{}) (string, error)
- func ToStringMapBoolE(i interface{}) (map[string]bool, error)
- func ToStringMapE(i interface{}) (map[string]interface{}, error)
- func ToStringMapInt64E(i interface{}) (map[string]int64, error)
- func ToStringMapIntE(i interface{}) (map[string]int, error)
- func ToStringMapStringE(i interface{}) (map[string]string, error)
- func ToStringMapStringSliceE(i interface{}) (map[string][]string, error)
- func ToStringSliceE(i interface{}) ([]string, error)
- func ToTimeE(i interface{}) (tim time.Time, err error)
- func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error)
- func ToUint16E(i interface{}) (uint16, error)
- func ToUint32E(i interface{}) (uint32, error)
- func ToUint64E(i interface{}) (uint64, error)
- func ToUint8E(i interface{}) (uint8, error)
- func ToUintE(i interface{}) (uint, error)
- func Uint(i interface{}) uint
- func Uint16(i interface{}) uint16
- func Uint32(i interface{}) uint32
- func Uint64(i interface{}) uint64
- func Uint8(i interface{}) uint8
- func UnsafeBytesToStr(b []byte) string
- func UnsafeStrToBytes(s string) []byte
Constants ¶
This section is empty.
Variables ¶
var ( // StructTagPriority defines the default priority tags for Map*/Struct* functions. // Note, the "gconv", "param", "params" tags are used by old version of package. // It is strongly recommended using short tag "c" or "p" instead in the future. StructTagPriority = []string{"gconv", "param", "params", "c", "p", "json"} )
Functions ¶
func BoolSlice ¶
func BoolSlice(i interface{}) []bool
BoolSlice casts an interface to a []bool type.
func DurationSlice ¶
DurationSlice casts an interface to a []time.Duration type.
func Int32ToString ¶
Int32ToString casts an interface to a string type.
func Interfaces ¶
func Interfaces(any interface{}) []interface{}
Interfaces converts `any` to []interface{}.
func Map ¶
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.
func MapStrStr ¶
MapStrStr converts `value` to map[string]string. Note that there might be data copy for this map type converting.
func Slice ¶
func Slice(i interface{}) []interface{}
Slice casts an interface to a []interface{} type.
func StringMap ¶
func StringMap(i interface{}) map[string]interface{}
StringMap casts an interface to a map[string]interface{} type.
func StringMapBool ¶
StringMapBool casts an interface to a map[string]bool type.
func StringMapInt ¶
StringMapInt casts an interface to a map[string]int type.
func StringMapInt64 ¶
StringMapInt64 casts an interface to a map[string]int64 type.
func StringMapString ¶
StringMapString casts an interface to a map[string]string type.
func StringMapStringSlice ¶
StringMapStringSlice casts an interface to a map[string][]string type.
func StringSlice ¶
func StringSlice(i interface{}) []string
StringSlice casts an interface to a []string type.
func StringToDate ¶
StringToDate attempts to parse a string into a time.Time type using a predefined list of formats. If no suitable format is found, an errors is returned.
func StringToDateInDefaultLocation ¶
StringToDateInDefaultLocation casts an empty interface to a time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.
func TimeInDefaultLocation ¶
func ToBoolSliceE ¶
ToBoolSliceE casts an interface to a []bool type.
func ToDurationE ¶
ToDurationE casts an interface to a time.Duration type.
func ToDurationSliceE ¶
ToDurationSliceE casts an interface to a []time.Duration type.
func ToFloat32E ¶
ToFloat32E casts an interface to a float32 type.
func ToFloat64E ¶
ToFloat64E casts an interface to a float64 type.
func ToIntSliceE ¶
ToIntSliceE casts an interface to a []int type.
func ToSliceE ¶
func ToSliceE(i interface{}) ([]interface{}, error)
ToSliceE casts an interface to a []interface{} type.
func ToStringMapBoolE ¶
ToStringMapBoolE casts an interface to a map[string]bool type.
func ToStringMapE ¶
ToStringMapE casts an interface to a map[string]interface{} type.
func ToStringMapInt64E ¶
ToStringMapInt64E casts an interface to a map[string]int64{} type.
func ToStringMapIntE ¶
ToStringMapIntE casts an interface to a map[string]int{} type.
func ToStringMapStringE ¶
ToStringMapStringE casts an interface to a map[string]string type.
func ToStringMapStringSliceE ¶
ToStringMapStringSliceE casts an interface to a map[string][]string type.
func ToStringSliceE ¶
ToStringSliceE casts an interface to a []string type.
func ToTimeInDefaultLocationE ¶
ToTimeInDefaultLocationE casts an empty interface to time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.
func UnsafeBytesToStr ¶
UnsafeBytesToStr converts []byte to string without memory copy. Note that, if you completely sure you will never use `b` variable in the feature, you can use this unsafe function to implement type conversion in high performance.
func UnsafeStrToBytes ¶
UnsafeStrToBytes converts string to []byte without memory copy. Note that, if you completely sure you will never use `s` variable in the feature, you can use this unsafe function to implement type conversion in high performance.
Types ¶
This section is empty.