Documentation
¶
Index ¶
- Constants
- Variables
- func AESDecrypt(text, key string) (string, error)
- func AESEncrypt(text, key string) (string, error)
- func ByteFormat(b int64) string
- func ByteParse(val string) (int64, error)
- func ByteToFloat64(bytes []byte) float64
- func BytesToInt(bys []byte) int
- func BytesToInt64(bys []byte) int64
- func Co(asyncFunc AsyncFunc, timeout time.Duration) error
- func Decimal(v float64) float64
- func DeepCopy(dst, src interface{}) error
- func Difference(slice1, slice2 []string) []string
- func DownloadPictureBytes(url string, timeout time.Duration) (res []byte, err error)
- func Float64ToByte(float float64) []byte
- func GetCurrentDirectory() string
- func Go(fn func())
- func Hash(s string) uint32
- func I2S[T Int](i T) string
- func InputCheck(input string) bool
- func Int64ToBytes(data int64) []byte
- func IntToBytes(n int) []byte
- func Intersect(slice1, slice2 []string) []string
- func Ints2String(ints []int) string
- func IsFileExists(path string) (bool, error)
- func IsSliceContain(slice []string, v string) bool
- func IsSliceEqual(a, b interface{}) bool
- func Kv2MapInt(in []Kv) (out map[int]int)
- func Kv2MapStr(in []Kv) (out map[string]string)
- func KvFormat(in []Kv) string
- func LabelsToString(labels map[string]string) string
- func MapKeyString2Int(in map[string]int) (out map[int]int)
- func MergeLabels(old map[string]string, new map[string]string) map[string]string
- func Page(from, to, size int64, fn func(from, to int64) error) error
- func RandStringBytes(n int) string
- func Recover() (err error)
- func S2I64(str string) int64
- func S2UI64(str string) uint64
- func SafeFunc(fn func()) (err error)
- func Strings2Map(ss []string) map[string]struct{}
- func SyncMapLen(m *sync.Map) int
- func UI2S[T Uint](i T) string
- func Union(slice1, slice2 []string) []string
- type AsyncFunc
- type Bytes
- type Int
- type Kv
- type Uint
Constants ¶
View Source
const ( KB MB GB TB PB EB )
View Source
const ( B = 1 KiB = 1024 * B MiB = 1024 * KiB GiB = 1024 * MiB )
View Source
const CoTimeout = time.Second
Variables ¶
View Source
var ErrAsyncFuncTimeout = errors.New("async func timeout")
Functions ¶
func AESDecrypt ¶
AESDecrypt Example of use
decrypted, err := AESDecrypt(encrypted, key) if err != nil { fmt.Println("Error decrypting:", err) return } fmt.Println("Decrypted:", decrypted)
func AESEncrypt ¶
AESEncrypt Example of use
key := "myverystrongpasswordo32bitlength" password := "mysecretpassword" encrypted, err := AESEncrypt(password, key) if err != nil { fmt.Println("Error encrypting:", err) return } fmt.Println("Encrypted:", encrypted)
func BytesToInt ¶
func BytesToInt64 ¶
func Co ¶
Co Description of function usage
errCo := x.Co(func(c context.Context) error { return f.xxx(ctx, aa, bb) }, x.CoTimeout) defer func() { if errCo != nil { if errors.Is(errCo, x.ErrAsyncFuncTimeout) { elog.Warn("file_vo_fill_tags", elog.FieldCtxTid(ctx.Request.Context()), l.E(err)) } else { elog.Error("file_vo_fill_tags", elog.FieldCtxTid(ctx.Request.Context()), l.E(err)) } } }()
func DownloadPictureBytes ¶
func InputCheck ¶
func Int64ToBytes ¶
func IntToBytes ¶
func Ints2String ¶
func IsSliceContain ¶
func LabelsToString ¶
func MergeLabels ¶
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 ¶
Page parses the function call by size from to, with closed intervals. For example: from=0 to=100 size=10 then the function is called 10 times, each time with from=0 to=10, from=10 to=20, from=20 to=30, ... , from=90 to=100
func RandStringBytes ¶
func Strings2Map ¶
func SyncMapLen ¶
Types ¶
type Bytes ¶
type Bytes struct{}
Bytes struct
type Kv ¶
type Kv struct { Key interface{} `json:"key"` Value interface{} `json:"value"` }
func MapString2Kv ¶
Click to show internal directories.
Click to hide internal directories.