Documentation
¶
Overview ¶
Package convert 类型转化
Index ¶
- func Convert(i interface{}, t string) interface{}
- func IPToUint(ipstr string) (uip uint32)
- func MapToStruct(m map[string]interface{}, o interface{}) error
- func Round(x float64, prec int) float64
- func RoundInt(x float64, prec int) int
- func ToBool(i interface{}) bool
- func ToBytes(i interface{}) []byte
- func ToFloat32(i interface{}) float32
- func ToFloat64(i interface{}) float64
- func ToInt(i interface{}) int
- func ToInt8(i interface{}) int8
- func ToInt16(i interface{}) int16
- func ToInt32(i interface{}) int32
- func ToInt64(i interface{}) int64
- func ToString(i interface{}) string
- func ToStringSlice(i interface{}) []string
- func ToTime(i interface{}, format ...string) time.Time
- func ToTimeDuration(i interface{}) time.Duration
- func ToUint(i interface{}) uint
- func ToUint8(i interface{}) uint8
- func ToUint16(i interface{}) uint16
- func ToUint32(i interface{}) uint32
- func ToUint64(i interface{}) uint64
- func UintToIP(uip uint32) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
func Convert(i interface{}, t string) interface{}
Convert 将变量i转换为字符串指定的类型t t: int,int8...[]byte,time.Time,time.Duration等
func MapToStruct ¶
MapToStruct 将map键值对映射到对应的struct对象属性上,需要注意: 1、第二个参数为struct对象指针; 2、struct对象的公开属性才能被映射赋值; 3、map中的键名可以为小写,映射转换时会自动将键名首字母转为大写做匹配映射,如果无法匹配则忽略;
func ToTimeDuration ¶
ToTimeDuration 将变量i转换为time.Duration类型
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.