utils

package
v2.2.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigBytesToInt

func BigBytesToInt(b []byte) int

BigBytesToInt 字节转整形

func BigIntToBytes

func BigIntToBytes(n int) []byte

BigIntToBytes 整形转字节

func FindServerConfig

func FindServerConfig(servers map[string]*treaty.Server, serverId string) *treaty.Server

FindServerConfig 查找服务器配置

func GenRangeInt added in v2.0.2

func GenRangeInt(length int, from int) []int

GenRangeInt 创建一个长度为length的slice 值为连续的整形,第一个数为from

func GetEnvDefault added in v2.2.2

func GetEnvDefault(key, defVal string) string

获取环境变量信息

func InStringSlice added in v2.0.2

func InStringSlice(finder string, slice []string) bool

InStringSlice 判断某个string值是否在切片中

func Int32ToString added in v2.0.3

func Int32ToString(val int32) string

Int32ToString 整数转字符串

func Int64ToString added in v2.0.3

func Int64ToString(val int64) string

Int64ToString 整数转字符串

func IntInSlice added in v2.0.2

func IntInSlice(finder int, slice []int) bool

IntInSlice 判断某个int值是否在切片中

func IntToString

func IntToString(val int) string

IntToString 整数转字符串

func IsSameSlice added in v2.0.2

func IsSameSlice(slice1, slice2 []int) bool

IsSameSlice 判断两个slice是否相等

func JsonMarshal added in v2.1.1

func JsonMarshal(data any) ([]byte, error)

func JsonUnmarshal added in v2.1.1

func JsonUnmarshal(data []byte, v any) error

func LittleBytesToInt

func LittleBytesToInt(b []byte) int

LittleBytesToInt 字节转整形

func LittleBytesToInt32

func LittleBytesToInt32(b []byte) int32

func LittleInt32ToBytes

func LittleInt32ToBytes(n int32) []byte

func LittleIntToBytes

func LittleIntToBytes(n int) []byte

LittleIntToBytes 整形转字节

func MapToSlice added in v2.0.2

func MapToSlice(m map[int]int) []int

MapToSlice 将map[int]count 转成 []int

func Md5

func Md5(str string) string

Md5 md5加密

func PathExists

func PathExists(path string) (bool, error)

func RangeRand added in v2.0.3

func RangeRand(min, max int) int

生成区间[-m, n]的安全随机数

func SafeRun

func SafeRun(f func())

func ShuffleSliceInt added in v2.0.2

func ShuffleSliceInt(src []int) []int

ShuffleSliceInt 打乱一个切片

func SliceCopy added in v2.0.2

func SliceCopy(s []int) []int

SliceCopy 拷贝一个切片

func SliceDel added in v2.0.2

func SliceDel(slice []int, values ...int) []int

SliceDel 删除slice中的某些元素

func SliceDelString added in v2.0.2

func SliceDelString(slice []string, values ...string) []string

SliceDelString 删除slice中的某些元素

func SliceJoin added in v2.0.2

func SliceJoin(s []int, joinString string) string

SliceJoin 将一个slice拼接成一个字符串

func SliceMaxInt added in v2.0.2

func SliceMaxInt(s []int) int

SliceMaxInt 取int类型的最大值

func SliceToMap added in v2.0.2

func SliceToMap(slice []int) map[int]int

SliceToMap 将[]int 转化成map[int]count

func SliceUniqueInt added in v2.0.2

func SliceUniqueInt(s []int) []int

SliceUniqueInt 去重

func StringToInt

func StringToInt(s string) int

func StringToInt32 added in v2.0.3

func StringToInt32(s string) int32

func StringToInt64 added in v2.0.3

func StringToInt64(s string) int64

func StringToUint added in v2.0.5

func StringToUint(s string) uint

func Stringify added in v2.1.1

func Stringify(data any) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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