cvt

package
v0.0.0-...-a8c716a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtoiSlice

func AtoiSlice(numbers []int) []string

func GetKeys

func GetKeys[T MapKey, V any](data map[T]V) []T

GetKeys 获取Map的key值列表

func GetValues

func GetValues[K MapKey, V any](data map[K]V) []V

GetValues 获取Map的key值列表

func IsNil

func IsNil(i interface{}) bool

func Round

func Round(f float64, n int) float64

func ToBoolean

func ToBoolean(v interface{}) bool

ToBoolean 将interface安全转换为bool.

func ToInt

func ToInt(v interface{}) int

ToInt 将interface安全转换为int.

func ToInt64

func ToInt64(v interface{}) int64

ToInt64 将interface安全转换为int64.

func ToMap

func ToMap(v interface{}) (map[string]interface{}, error)

ToMap 将interface转换为map. 如果参数是字符串,则尝试进行json反序列化. 如果参数是interface{}/map[string]interface{}数组,则将数组第一个元素进行转换. 如果参数是其他类型,则先调用json进行序列化,再把结果进行反序列化.

func ToMaps

func ToMaps(v interface{}) ([]map[string]interface{}, error)

func ToNumber

func ToNumber(v interface{}) float64

ToNumber 将interface安全转换为number.

func ToString

func ToString(value interface{}) string

ToString interface{}转string nolint

func ToStringWithDefault

func ToStringWithDefault(value interface{}, def string) string

Types

type MapKey

type MapKey interface {
	constraints.Ordered | ~bool
}

Jump to

Keyboard shortcuts

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