xx2

package
v0.0.0-...-5ea3ca1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func CompressZLib

func CompressZLib(src []byte) ([]byte, error)

func Copy

func Copy(src interface{}, dst interface{}) error

Copy msgpack.Marshal to msgpack.Unmarshal

func CopySlice

func CopySlice[T any](src []T) []T

CopySlice creates and returns a copy of the provided slice.

func DecryptUnCompressUnpackTo

func DecryptUnCompressUnpackTo(src []byte, dst interface{}, key, iv string) (err error)

func DecryptUnpack

func DecryptUnpack(src []byte, key, iv string) (dst interface{}, err error)

func Default

func Default[T comparable](value T, defaultValue T) T

Default provides a default value for various types when the main value is its type's zero value.

func DefaultSlice

func DefaultSlice[T any](s []T, defaultS []T, notCopy ...int) []T

DefaultSlice provides a copy of the given slice if it's not empty, or a copy of the default value slice otherwise, based on the copy flag. The copy flag is optional and defaults to false if not provided.

func Encrypt

func Encrypt(plainText, key, iv string) (dst []byte, err error)

func EqualSlice

func EqualSlice[T comparable](a, b []T) bool

EqualSlice Compare two slices to see if they are the same, in the same order and with the same value.

func First

func First[T any](s []T) T

First returns the first element of a collection or error if empty.

func IfError

func IfError(condition bool, i interface{}) error

func InRange

func InRange[T Comparable](i, minVal, maxVal T) T

InRange 限定范围 min <= i <= max

func IsPointer

func IsPointer(value interface{}) error

func IsUuid

func IsUuid(i string) bool

func Pack

func Pack(src interface{}) ([]byte, error)

func PackCompress

func PackCompress(src interface{}) ([]byte, error)

func PackCompressEncrypt

func PackCompressEncrypt(src interface{}, key, iv string) (dst []byte, err error)

PackCompressEncrypt Note that the key must be 16/24/32 bit length.

func Round

func Round(i float64, digits int) float64

func Round0

func Round0(i float64) float64

func Round1

func Round1(i float64) float64

func Round2

func Round2(i float64) float64

func Round3

func Round3(i float64) float64

func Round4

func Round4(i float64) float64

func Round5

func Round5(i float64) float64

func Round6

func Round6(i float64) float64

func SafeFilename

func SafeFilename(i string) string

func Sha1

func Sha1(v interface{}) string

Sha1 returns the SHA1 digest of the data. (Result Length: 40 bits)

func Sha3

func Sha3(v interface{}) string

Sha3 returns the SHA3-256 digest of the data. (Result Length : 64 bits)

func Sha3Bytes

func Sha3Bytes(v []byte) string

Sha3Bytes returns the SHA3-256 digest of the data. (Result Length : 64 bits)

func Sha3File

func Sha3File(path string) (string, error)

Sha3File returns the SHA3-256 digest of the data. (Result Length : 64 bits)

func Sleep

func Sleep(s float64, show ...int)

Sleep Second

func SubStringHan

func SubStringHan(s string, n int) string

SubStringHan 返回一个字符串的前 n 个字符,其中中文字符的长度为 2:

func T1

func T1(title ...string)

func T2

func T2(title ...string) float64

func UnCompressUnpack

func UnCompressUnpack(src []byte) (dst interface{}, err error)

func UnCompressUnpackTo

func UnCompressUnpackTo(src []byte, dst interface{}) (err error)

func UnCompressZLib

func UnCompressZLib(src []byte) ([]byte, error)

func Unpack

func Unpack(src []byte) (dst interface{}, err error)

func UnpackTo

func UnpackTo(src []byte, dst interface{}) (err error)

func Zzz

func Zzz(title ...string)

Types

type Comparable

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

type Ip2LocationRecord

type Ip2LocationRecord struct {
	CountryShort string
	Country      string
	Province     string // Region Province
	City         string
}

func Ip2Location

func Ip2Location(ipList []string) ([]*Ip2LocationRecord, error)

Ip2Location ... Country / CountryShort / Province / City

type PsInfo

type PsInfo struct {
	Memory PsInfoItem
	Disk   PsInfoItem
	Load   PsInfoLoad
	Uptime uint64
}

func GetPsInfo

func GetPsInfo() (a PsInfo)

GetPsInfo ...

type PsInfoItem

type PsInfoItem struct {
	Total       float64
	Used        float64
	Free        float64
	UsedPercent float64
}

type PsInfoLoad

type PsInfoLoad struct {
	Avg1  float64
	Avg5  float64
	Avg15 float64
}

Jump to

Keyboard shortcuts

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