x

package module
v0.0.0-...-da93e03 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KB
	MB
	GB
	TB
	PB
	EB
)

Variables

This section is empty.

Functions

func AsyncCall

func AsyncCall(f func())

func ByteFormat

func ByteFormat(b int64) string

ByteFormat wraps global Bytes's Format function.

func ByteParse

func ByteParse(val string) (int64, error)

ByteParse wraps global Bytes's Parse function.

func ByteToFloat64

func ByteToFloat64(bytes []byte) float64

ByteToFloat64 byte转Float64

func BytesToInt

func BytesToInt(bys []byte) int

func BytesToInt64

func BytesToInt64(bys []byte) int64

func Decimal

func Decimal(v float64) float64

func DeepCopy

func DeepCopy(dst, src interface{}) error

DeepCopy 深度拷贝

func Difference

func Difference(slice1, slice2 []string) []string

Difference 求差集 slice1-并集

func Float64ToByte

func Float64ToByte(float float64) []byte

Float64ToByte Float64转byte

func Go

func Go(fn func())

Go goroutine

func Hash

func Hash(s string) uint32

func I2S

func I2S[T Int](i T) string

func InputCheck

func InputCheck(input string) bool

func Int64ToBytes

func Int64ToBytes(data int64) []byte

func IntToBytes

func IntToBytes(n int) []byte

func Intersect

func Intersect(slice1, slice2 []string) []string

Intersect 求交集

func Ints2String

func Ints2String(ints []int) string

func IsSliceEqual

func IsSliceEqual(a, b interface{}) bool

IsSliceEqual ..

func Kv2MapInt

func Kv2MapInt(in []Kv) (out map[int]int)

func Kv2MapStr

func Kv2MapStr(in []Kv) (out map[string]string)

func KvFormat

func KvFormat(in []Kv) string

KvFormat TCP:9001,TCP:9003

func LabelsToString

func LabelsToString(labels map[string]string) string

func MapKeyString2Int

func MapKeyString2Int(in map[string]int) (out map[int]int)

func MergeLabels

func MergeLabels(old map[string]string, new map[string]string) map[string]string

MergeLabels merge label the new map will overwrite the old one. e.g. new: {"foo": "newbar"} old: {"foo": "bar"} will return {"foo": "newbar"}

func Page

func Page(from, to, size int64, fn func(from, to int64) error) error

通过入参 from to 根据 size 对函数调用进行分页查询,闭区间 例如:from=0 to=100 size=10 则会调用 10 次函数,每次入参为 from=0 to=10, from=10 to=20, from=20 to=30, ..., from=90 to=100

func S2I64

func S2I64(str string) int64

func S2UI64

func S2UI64(str string) uint64

func Strings2Map

func Strings2Map(ss []string) map[string]struct{}

func SyncMapLen

func SyncMapLen(m *sync.Map) int

func UI2S

func UI2S[T Uint](i T) string

func Union

func Union(slice1, slice2 []string) []string

Union 求并集

Types

type Bytes

type Bytes struct{}

Bytes struct

func New

func New() *Bytes

New creates a Bytes instance.

func (*Bytes) Format

func (*Bytes) Format(b int64) string

Format formats bytes integer to human readable string. For example, 31323 bytes will return 30.59KB.

func (*Bytes) Parse

func (*Bytes) Parse(value string) (i int64, err error)

Parse parses human readable bytes string to bytes integer. For example, 6GB (6G is also valid) will return 6442450944.

type Int

type Int interface {
	~int8 | ~int16 | ~int32 | ~int64 | ~int
}

type Kv

type Kv struct {
	Key   interface{} `json:"key"`
	Value interface{} `json:"value"`
}

func KvUnFormat

func KvUnFormat(in string) []Kv

KvUnFormat TCP:9001,TCP:9003

func MapInt2Kv

func MapInt2Kv(in map[int]int) []Kv

func MapString2Kv

func MapString2Kv(in map[string]string) []Kv

type Uint

type Uint interface {
	~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uint
}

Jump to

Keyboard shortcuts

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