pkg

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToStr

func ByteToStr(b []byte) string

ByteToStr 高效转换,避免内存拷贝,

func CallMethod added in v1.2.1

func CallMethod(v interface{}, methodName string) (interface{}, bool)

func Interpret added in v1.2.1

func Interpret(a interface{}) interface{}

func IsBaseType

func IsBaseType(v interface{}) bool

func IsStrType added in v1.2.1

func IsStrType(v interface{}) (bool, string)

func JsonChecker added in v1.2.1

func JsonChecker(v interface{}) (bool, string)

StrChecker 判断v是不是一个字符串类型,首先判断是否为字符串,其次判断是否为json 注:基础类型也会返回true,如:"745934759",返回true,序列化为json.Number

func JsonDumps

func JsonDumps(m interface{}) (string, error)

func JsonLoadsList

func JsonLoadsList(jsonStr string) ([]interface{}, error)

JsonLoadsList

func JsonLoadsMap added in v1.2.1

func JsonLoadsMap(jsonStr string) (map[string]interface{}, error)

JsonLoadsMap Tip: map类型的json key必须是字符串;

func JsonLoadsObj added in v1.2.1

func JsonLoadsObj(jsonStr string, o interface{}) (interface{}, error)

JsonLoadsObj 注:o必须是对象的指针

func JsonUnmarshalObj added in v1.2.1

func JsonUnmarshalObj(jsonStr string, o interface{}) (interface{}, error)

JsonUnmarshalObj 注:o必须是对象的指针

func MapToStruct added in v1.2.1

func MapToStruct(inputMap interface{}, outputStruct interface{}) (interface{}, error)

func ReflectToVal added in v1.2.1

func ReflectToVal(v interface{}) reflect.Value

func StrToByte

func StrToByte(s string) (b []byte)

StrToByte 高效转换,避免内存拷贝

func ToFloat32

func ToFloat32(v interface{}) (float32, error)

func ToFloat64

func ToFloat64(v interface{}) (float64, error)

ToFloat64 如果v是int64或uint64,会进行强转,数字超过float64最大数值可能丢失精度

func ToInt64

func ToInt64(v interface{}) (int64, error)

ToInt64 如果v是float或uint,会进行强转,uint超过int64的最大数值可能丢失精度

func ToStr

func ToStr(v interface{}) string

func UniqByReflect added in v1.2.1

func UniqByReflect(data interface{}) interface{}

func UniqList added in v1.2.1

func UniqList(data interface{}) interface{}

Types

type InterfaceType

type InterfaceType int
const (
	UnImplementInterface InterfaceType = 0
	ListInterface        InterfaceType = 1
	MapInterface         InterfaceType = 2
)

func GetInterfaceType

func GetInterfaceType(i interface{}) InterfaceType

type ValType

type ValType int
const (
	UnKnownType ValType = 0

	Str     ValType = 1
	Int     ValType = 2
	Int64   ValType = 3
	Int32   ValType = 4
	Uint    ValType = 5
	Uint64  ValType = 6
	Uint32  ValType = 7
	Float32 ValType = 8
	Float64 ValType = 9
	Bool    ValType = 10

	Map   ValType = 21
	Array ValType = 32
	Slice ValType = 23

	Struct ValType = 41
	Ptr    ValType = 42
	Func   ValType = 43

	MapStrItf     ValType = 61
	MapIntItf     ValType = 62
	MapInt32Itf   ValType = 63
	MapInt64Itf   ValType = 64
	MapUintItf    ValType = 65
	MapUint32Itf  ValType = 66
	MapUint64Itf  ValType = 67
	MapFloatItf   ValType = 68
	MapFloat64Itf ValType = 69
	MapStructItf  ValType = 70
	MapFuncItf    ValType = 71

	MapStrToStr         ValType = 72
	MapIntToInt         ValType = 73
	MapInt64ToInt64     ValType = 74
	MapFloat32ToFloat32 ValType = 75
	MapFloat64ToFloat64 ValType = 76

	ListItf     ValType = 81
	ListStr     ValType = 82
	ListInt     ValType = 83
	ListInt64   ValType = 84
	ListInt32   ValType = 85
	ListUint    ValType = 86
	ListUint32  ValType = 87
	ListUint64  ValType = 88
	ListFloat32 ValType = 89
	ListFloat64 ValType = 90
	ListBool    ValType = 91
)

Jump to

Keyboard shortcuts

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