typeHelper

package
v1.5.54 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Int added in v1.5.6

func Bytes2Int(b []byte) int

字节转换成整形

func Empty

func Empty(arg interface{}) bool

*

  • @func: Empty 判断目标是否为空值或0
  • @author Wiidz
  • @date 2019-11-16

func Explode

func Explode(data string, sep string) []interface{}

*

  • @func: Explode 字符串转slice, 接受混合类型
  • @author Wiidz
  • @date 2019-11-16

func ExplodeFloat64

func ExplodeFloat64(data string, sep string) []float64

*

  • @func: Explode 字符串转int slice
  • @author Wiidz
  • @date 2019-11-16

func ExplodeInt

func ExplodeInt(data string, sep string) []int

*

  • @func: Explode 字符串转int slice
  • @author Wiidz
  • @date 2019-11-16

func ExplodeInt8 added in v1.5.6

func ExplodeInt8(data string, sep string) []int8

ExplodeInt8 字符串转int8 slice

func ExplodeInt64

func ExplodeInt64(data string, sep string) []int64

*

  • @func: Explode 字符串转int slice
  • @author Wiidz
  • @date 2019-11-16

func ExplodeStr added in v1.5.6

func ExplodeStr(data string, sep string) []string

*

  • @func: ExplodeStr 字符串转str clise
  • @author Wiidz
  • @date 2019-11-16

func ExplodeUint64 added in v1.5.6

func ExplodeUint64(data string, sep string) []uint64

*

  • @func: ExplodeUint64 字符串转int slice
  • @author Wiidz
  • @date 2019-11-16

func Float64Slice2Int added in v1.5.6

func Float64Slice2Int(data []float64) []int

Float64Slice2Int Float64切片转int切片

func Float64Slice2Int8 added in v1.5.6

func Float64Slice2Int8(data []float64) []int8

Float64Slice2Int8 Float64切片转int8切片

func Float64Slice2Str added in v1.5.6

func Float64Slice2Str(data []float64) []string

Float64Slice2Str Float64切片转str切片

func Float64Slice2Uint64 added in v1.5.6

func Float64Slice2Uint64(data []float64) []uint64

Float64Slice2Uint64 Float64切片转uint64切片

func Float64ToInt added in v1.5.6

func Float64ToInt(number float64) int

Float64ToInt float64转int

func Float64ToInt8 added in v1.5.6

func Float64ToInt8(number float64) int8

*

  • @func: Float64ToInt8 将字符串转为int8
  • @author Wiidz
  • @date 2019-11-16

func Float64ToInt64 added in v1.5.6

func Float64ToInt64(number float64) int64

Float64ToInt64 float64转为int64

func Float64ToStr

func Float64ToStr(number float64) string

*

  • @func: Str2Int 将字符串转为int
  • @author Wiidz
  • @date 2019-11-16

func Float64ToUint64 added in v1.5.6

func Float64ToUint64(number float64) uint64

*

  • @func: Float64ToUint64 将字符串转为int8
  • @author Wiidz
  • @date 2019-11-16

func ForceFloat64 added in v1.5.6

func ForceFloat64(value interface{}) float64

ForceFloat64 强制转换为Float64

func ForceFloat64Slice added in v1.5.6

func ForceFloat64Slice(value interface{}) []float64

ForceFloat64Slice 强制转换成float64切片

func ForceInt added in v1.5.6

func ForceInt(value interface{}) int

ForceInt 强制转换为int

func ForceInt8 added in v1.5.6

func ForceInt8(value interface{}) int8

ForceInt8 强制转换为int8

func ForceInt8Slice added in v1.5.6

func ForceInt8Slice(value interface{}) []int8

ForceInt8Slice 强制转换成int8切片

func ForceIntSlice added in v1.5.6

func ForceIntSlice(value interface{}) []int

ForceIntSlice 强制转换成int64切片

func ForceStrSlice added in v1.5.6

func ForceStrSlice(value interface{}) []string

ForceStrSlice 强制转换成str切片

func ForceString added in v1.5.6

func ForceString(value interface{}) string

ForceString 强制转换为string

func ForceUint64 added in v1.5.6

func ForceUint64(value interface{}) uint64

ForceUint64 强制转换为Uint64

func ForceUint64Slice added in v1.5.6

func ForceUint64Slice(value interface{}) []uint64

ForceUint64Slice 强制转换成uint64切片

func GetType

func GetType(params interface{}) string

*

  • @func: GetType 获取目标的数据类型
  • @author Wiidz
  • @date 2019-11-16

func If

func If(conditions bool, trueVal, falseVal interface{}) interface{}

*

  • @func: If 三元运算符
  • @author Wiidz
  • @date 2019-11-16

func Implode

func Implode(data interface{}, glue string) string

*

  • @func: Implode 将slice转换成字符串
  • @author Wiidz
  • @date 2019-11-16

func ImplodeInt added in v1.5.6

func ImplodeInt(data []int, glue string) string

*

  • @func: ImplodeInt 将int slice转换成字符串
  • @author Wiidz
  • @date 2019-11-16

func ImplodeInt8 added in v1.5.6

func ImplodeInt8(data []int8, glue string) string

ImplodeInt8 将Int8切片转换成string

func ImplodeStr added in v1.5.6

func ImplodeStr(data []string, glue string) string

ImplodeStr 将 str slice转换成字符串

func ImplodeUint64 added in v1.5.6

func ImplodeUint64(data []uint64, glue string) string

ImplodeUint64 将slice转换成字符串

func Int2Bytes added in v1.5.6

func Int2Bytes(n int) []byte

整形转换成字节

func Int2Str

func Int2Str(number int) string

*

  • @func: Float64SliceToInt float64 slice转换成 int slice
  • @author Wiidz
  • @date 2019-11-16

func Int8Slice2Float64 added in v1.5.6

func Int8Slice2Float64(data []int8) []float64

Int8Slice2Float64 Int8切片转float64切片

func Int8Slice2Int added in v1.5.6

func Int8Slice2Int(data []int8) []int

Int8Slice2Int Int8切片转int切片

func Int8Slice2Str added in v1.5.6

func Int8Slice2Str(data []int8) []string

Int8Slice2Str Int8切片转str切片

func Int8Slice2Uint64 added in v1.5.6

func Int8Slice2Uint64(data []int8) []uint64

Int8Slice2Uint64 Int8切片转uint64切片

func Int8ToStr added in v1.5.6

func Int8ToStr(number int8) string

Int8ToStr int8转字符串

func Int64ToStr

func Int64ToStr(number int64) string

*

  • @func: Int64ToStr int64转为str
  • @author Wiidz
  • @date 2019-11-16

func IntSlice2Float64 added in v1.5.6

func IntSlice2Float64(data []int) []float64

IntSlice2Float64 Int切片转float64切片

func IntSlice2Int8 added in v1.5.6

func IntSlice2Int8(data []int) []int8

IntSlice2Int8 Int切片转int8切片

func IntSlice2Str added in v1.5.6

func IntSlice2Str(data []int) []string

IntSlice2Str Int切片转str切片

func IntSlice2Uint64 added in v1.5.6

func IntSlice2Uint64(data []int) []uint64

IntSlice2Uint64 Int切片转uint64切片

func InterfaceMapToStr added in v1.5.6

func InterfaceMapToStr(data map[string]interface{}) map[string]string

InterfaceMapToStr 把map[string]interface{} 转换成 map[string]string

func InterfaceSlice2MapSlice

func InterfaceSlice2MapSlice(inter []interface{}) []map[string]interface{}

InterfaceSlice2MapSlice

func IsNil

func IsNil(i interface{}) bool

func IsType

func IsType(needle interface{}, type_name string) bool

*

  • @func: IsType 判断目标是否为指定类型的值
  • @author Wiidz
  • @date 2019-11-16

func JsonDecode

func JsonDecode(jsonStr string) (parsedData interface{})

func JsonDecodeFloat64Slice added in v1.5.6

func JsonDecodeFloat64Slice(jsonStr string) []float64

JsonDecodeFloat64Slice json解码至float6464切片

func JsonDecodeInt64Slice

func JsonDecodeInt64Slice(jsonStr string, config *jsoniter.Config) []int64

JsonDecodeInt64Slice json解码至int64切片

func JsonDecodeIntSlice added in v1.5.6

func JsonDecodeIntSlice(jsonStr string, config *jsoniter.Config) []int

JsonDecodeIntSlice json解码至int切片

func JsonDecodeMap added in v1.5.6

func JsonDecodeMap(jsonStr string) (parsedData map[string]interface{})

JsonDecodeMap 修复

func JsonDecodeMapStr added in v1.5.6

func JsonDecodeMapStr(jsonStr string) (parsedData map[string]string)

func JsonDecodeMapWithConfig added in v1.5.6

func JsonDecodeMapWithConfig(jsonStr string, config jsoniter.Config) (parsedData map[string]interface{})

JsonDecodeMapWithConfig UseNumber:true 1.JSON 数值类型的默认解析规则 Go 的 encoding/json 库(以及兼容模式的 jsoniter)在解析 JSON 数值时,若数值较大(超过 int64 范围),会优先解析为 float64 类型 。例如,10000001 会被解析为 1.0000001e+07,这是浮点数的科学计数法表示。 2.map[string]interface{} 的类型推断 使用 map[string]interface{} 接收 JSON 数据时,解析器会根据数值大小自动选择 float64 或 int 类型。由于 10000001 在 Go 的 int 类型范围内(32 位系统下可能超出),解析器可能仍选择 float64 以避免溢出风险。

func JsonDecodeSliceMap added in v1.5.6

func JsonDecodeSliceMap(jsonStr string) (parsedData []map[string]interface{})

func JsonDecodeStrSlice added in v1.5.6

func JsonDecodeStrSlice(jsonStr string) []string

JsonDecodeStrSlice json解码至str切片

func JsonDecodeUint64Slice added in v1.5.6

func JsonDecodeUint64Slice(jsonStr string) []uint64

JsonDecodeUint64Slice json解码至uint64切片

func JsonDecodeWithStruct

func JsonDecodeWithStruct(jsonStr string, iStruct interface{}) error

JsonDecodeWithStruct 带结构体的json解码

temp := ReGeoRes{}
typeHelper.JsonDecodeWithStruct(tempStr,&temp)

func JsonEncode

func JsonEncode(data interface{}) (string, error)

*

  • @func: JsonEncode 编码json 注意这种方法可能会保留转义符号
  • @author Wiidz
  • @date 2019-11-16

func JsonEncodeDecodeMap added in v1.5.6

func JsonEncodeDecodeMap(data interface{}) (map[string]interface{}, error)

JsonEncodeDecodeMap 将任何数据转换成map[string]interface{}

func Map2InterfaceSlice

func Map2InterfaceSlice(data map[string]interface{}) []interface{}

Map2InterfaceSlice 将map转换成interface slice

func Str2Float64

func Str2Float64(str string) float64

*

  • @func: Str2Float64 str转为float64
  • @author Wiidz
  • @date 2019-11-16

func Str2Int

func Str2Int(str string) int

*

  • @func: Str2Int 将字符串转为int
  • @author Wiidz
  • @date 2019-11-16

func Str2Int8

func Str2Int8(str string) int8

*

  • @func: Str2Int8 将字符串转为int8
  • @author Wiidz
  • @date 2019-11-16

func Str2Int64

func Str2Int64(str string) int64

*

  • @func: Str2Int64 将字符串转为int64
  • @author Wiidz
  • @date 2019-11-16

func Str2Uint added in v1.5.6

func Str2Uint(str string) (res uint, err error)

Str2Uint 将字符串转为uint @author Wiidz @date 2023-12-19

func Str2Uint64 added in v1.5.6

func Str2Uint64(str string) uint64

*

  • @func: Str2Int8 将字符串转为int8
  • @author Wiidz
  • @date 2019-11-16

func StrMapToInterface added in v1.5.6

func StrMapToInterface(data map[string]string) map[string]interface{}

StrMapToInterface 把map[string]string 转换成 map[string]interface{}

func StrSlice2Float64 added in v1.5.6

func StrSlice2Float64(data []string) []float64

StrSlice2Float64 Str切片转float64切片

func StrSlice2Int added in v1.5.6

func StrSlice2Int(data []string) []int

StrSlice2Int Str切片转int切片

func StrSlice2Int8 added in v1.5.6

func StrSlice2Int8(data []string) []int8

StrSlice2Int8 Str切片转int8切片

func StrSlice2InterfaceSlice

func StrSlice2InterfaceSlice(data []string) []interface{}

*

  • @func: StrSlice2InterfaceSlice 字符串slice转interface slice
  • @author Wiidz
  • @date 2019-11-16

func StrSlice2Uint64 added in v1.5.6

func StrSlice2Uint64(data []string) []uint64

StrSlice2Uint64 Str切片转uint64切片

func StructToMap added in v1.5.6

func StructToMap(obj interface{}) (result map[string]interface{}, err error)

StructToMap 结构体转换为map

func ToString

func ToString(data interface{}) string

*

  • @func: ToString 将任何参数转换为字符串
  • @author Wiidz
  • @date 2019-11-16

func Uint64Slice2Float64 added in v1.5.6

func Uint64Slice2Float64(data []uint64) []float64

Uint64Slice2Float64 Uint64切片转float64切片

func Uint64Slice2Int added in v1.5.6

func Uint64Slice2Int(data []uint64) []int

Uint64Slice2Int Uint64切片转int切片

func Uint64Slice2Int8 added in v1.5.6

func Uint64Slice2Int8(data []uint64) []int8

Uint64Slice2Int8 Uint64切片转int8切片

func Uint64Slice2Str added in v1.5.6

func Uint64Slice2Str(data []uint64) []string

Uint64Slice2Str Uint64切片转str切片

func Uint64ToStr added in v1.5.6

func Uint64ToStr(number uint64) string

*

  • @func: Float64SliceToInt float64 slice转换成 int slice
  • @author Wiidz
  • @date 2019-11-16

func UintToStr added in v1.5.6

func UintToStr(number uint) string

UintToStr uint 转换成 str

Types

type Kind added in v1.5.6

type Kind string
const (
	Invalid       Kind = "invalid"
	Bool          Kind = "bool"
	Int           Kind = "int"
	Int8          Kind = "int8"
	Int16         Kind = "int16"
	Int32         Kind = "int32"
	Int64         Kind = "int64"
	Uint          Kind = "uint"
	Uint8         Kind = "uint8"
	Uint16        Kind = "uint16"
	Uint32        Kind = "uint32"
	Uint64        Kind = "uint64"
	Uintptr       Kind = "uintptr"
	Float32       Kind = "float32"
	Float64       Kind = "float64"
	Complex64     Kind = "complex64"
	Complex128    Kind = "complex128"
	Array         Kind = ""
	Chan          Kind = ""
	Func          Kind = ""
	Interface     Kind = "interface{}"
	Map           Kind = ""
	Ptr           Kind = ""
	Slice         Kind = ""
	String        Kind = "string"
	Struct        Kind = ""
	UnsafePointer Kind = ""
)

Jump to

Keyboard shortcuts

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