xconv

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(i interface{}, def ...bool) bool

func Byte

func Byte(i interface{}) byte

Byte converts <i> to byte.

func Bytes

func Bytes(i interface{}) []byte

Bytes converts <i> to []byte.

func Convert

func Convert(i interface{}, t string, params ...interface{}) interface{}

Convert converts the variable <i> to the type <t>, the type <t> is specified by string. The unnecessary parameter <params> is used for additional parameter passing.

func Duration

func Duration(i interface{}) time.Duration

字符串或时间戳转换成time.Duration

func Float

func Float(i interface{}, def ...float32) float32

func Float32

func Float32(i interface{}, def ...float32) float32

Float32 converts <i> to float32.

func Float64

func Float64(i interface{}, def ...float64) float64

Float64 converts <i> to float64.

func Floats

func Floats(i interface{}) []float64

Strings converts <i> to []float64.

func Int

func Int(i interface{}, def ...int) int

Int converts <i> to int.

func Int16

func Int16(i interface{}, def ...int16) int16

Int16 converts <i> to int16.

func Int32

func Int32(i interface{}, def ...int32) int32

Int32 converts <i> to int32.

func Int64

func Int64(v interface{}, def ...int64) int64

func Int8

func Int8(i interface{}, def ...int8) int8

Int8 converts <i> to int8.

func Interfaces

func Interfaces(i interface{}) []interface{}

Interfaces converts <i> to []interface{}.

func Ints

func Ints(i interface{}) []int

Ints converts <i> to []int.

func Map

func Map(value interface{}, tags ...string) map[string]interface{}

其他类型转换成map[string]interface类型

func MapDeep

func MapDeep(value interface{}, tags ...string) map[string]interface{}

struct转换成map[string]interface, 取取内层struct的字段

func Maps

func Maps(value interface{}, tags ...string) []map[string]interface{}

Maps converts <i> to []map[string]interface{}.

func MapsDeep

func MapsDeep(value interface{}, tags ...string) []map[string]interface{}

MapsDeep converts <i> to []map[string]interface{} recursively.

func Rune

func Rune(i interface{}) rune

Rune converts <i> to rune.

func Runes

func Runes(i interface{}) []rune

Runes converts <i> to []rune.

func SliceAny

func SliceAny(i interface{}) []interface{}

SliceAny is alias of Interfaces.

func SliceFloat

func SliceFloat(i interface{}) []float64

SliceFloat is alias of Floats.

func SliceInt

func SliceInt(i interface{}) []int

SliceInt is alias of Ints.

func SliceMap

func SliceMap(i interface{}) []map[string]interface{}

SliceMap is alias of Maps.

func SliceMapDeep

func SliceMapDeep(i interface{}) []map[string]interface{}

SliceMapDeep is alias of MapsDeep.

func SliceStr

func SliceStr(i interface{}) []string

SliceStr is alias of Strings.

func SliceStruct

func SliceStruct(params interface{}, pointer interface{}, mapping ...map[string]string) (err error)

SliceStruct is alias of Structs.

func SliceStructDeep

func SliceStructDeep(params interface{}, pointer interface{}, mapping ...map[string]string) (err error)

SliceStructDeep is alias of StructsDeep.

func String

func String(v interface{}, def ...string) string

func Strings

func Strings(i interface{}) []string

Strings converts <i> to []string.

func Struct

func Struct(params interface{}, pointer interface{}, mapping ...map[string]string) error

使用字典map设置struct字段值 params 设置struct字段值的数据字典, 字段名不区分大小写 mapping 字典键名key与struct字段名映射关系

func StructDeep

func StructDeep(params interface{}, pointer interface{}, mapping ...map[string]string) error

使用字典map设置struct字段值包括内嵌struct params 设置struct字段值的数据字典, 字段名不区分大小写 mapping 字典键名key与struct字段名映射关系

func Structs

func Structs(params interface{}, pointer interface{}, mapping ...map[string]string) (err error)

func StructsDeep

func StructsDeep(params interface{}, pointer interface{}, mapping ...map[string]string) (err error)

func Time

func Time(i interface{}, format ...string) time.Time

转换成time.Time

func Uint

func Uint(i interface{}, def ...uint) uint

Uint converts <i> to uint.

func Uint16

func Uint16(i interface{}, def ...uint16) uint16

Uint16 converts <i> to uint16.

func Uint32

func Uint32(i interface{}, def ...uint32) uint32

Uint32 converts <i> to uint32.

func Uint64

func Uint64(i interface{}, def ...uint64) uint64

Uint64 converts <i> to uint64.

func Uint8

func Uint8(i interface{}, def ...uint8) uint8

Uint8 converts <i> to uint8.

func XTime

func XTime(i interface{}, format ...string) *xtime.Time

转换成xtime

Types

type IString

type IString interface {
	String() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL