utils

package
v0.0.0-...-8218024 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToInterface

func ByteToInterface(byteMsg []byte) (interface{}, error)

func ByteToMap

func ByteToMap(msg []byte) (map[string]interface{}, error)

func DecimalMath

func DecimalMath(str string) int32

获取精度数据

func FormatFloat

func FormatFloat(number float64, precision int) string

func GenBase64Digest

func GenBase64Digest(h hash.Hash) string

GenBase64Digest 返回加密后的base64编码的字符串

func GenHexDigest

func GenHexDigest(h hash.Hash) string

GenHexDigest 返回加密后的16进制字符串

func GenerateOrderId

func GenerateOrderId(prefix string, length int) string

func GenerateRangeNum

func GenerateRangeNum(min, max int64) int64

func HmacSha256

func HmacSha256(message string, secret string) hash.Hash

HmacSha256 计算Hmac Sha256签名串

func HmacSha512

func HmacSha512(message string, secret string) hash.Hash

HmacSha512 计算Hmac Sha512签名串

func IsoTime

func IsoTime() string

IsoTime eg: 2018-03-16T18:02:48.284Z

func JsonDecode

func JsonDecode(jsonBytes []byte, result interface{}) error

func Microsec

func Microsec(t time.Time) int64

func Millisec

func Millisec(t time.Time) int64

func ParseFloat

func ParseFloat(str string) (float64, error)

func ParseInt

func ParseInt(str string) (int64, error)

func RandomString

func RandomString(n int) string

RandomString 随机

func RandomString64

func RandomString64() string

RandomString64 生成长度位64得随机字符串

func ScaleFloat

func ScaleFloat(number float64, precision int, roundUp string) float64

func Sha512Str

func Sha512Str(src string) string

Sha512Str

func UrlEncodeParams

func UrlEncodeParams(paramsDict map[string]interface{}) string

UrlEncodeParams 对query参数进行url编码,不要求参数顺序

func UrlEncodeParamsByKeys

func UrlEncodeParamsByKeys(paramsDict map[string]interface{}, keys []string) string

UrlEncodeParamsByKeys 对query参数进行url编码,根据传入的keys顺序进行处理

Types

type RandomStringer

type RandomStringer struct {
	// contains filtered or unexported fields
}

RandomStringer 不加锁,使用者自己保证线程安全

func NewRandomStringer

func NewRandomStringer() *RandomStringer

func (*RandomStringer) RandomString

func (r *RandomStringer) RandomString(n int) string

RandomString 随机

func (*RandomStringer) RandomTracingID

func (r *RandomStringer) RandomTracingID() string

Jump to

Keyboard shortcuts

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