Documentation ¶
Index ¶
- Constants
- Variables
- func ArrContains[T comparable](s []T, e T) bool
- func ByteToStruct[T any](byteChan <-chan []byte, outChan chan<- T)
- func DecToPrec(num string, countMode int, precision string, isRound, padZero bool) (string, error)
- func Eddsa(request []byte, secret []byte) (string, error)
- func EncodeToLatin1(input string) ([]byte, error)
- func EncodeURIComponent(str string, safe string) string
- func EqualIn(a, b, thres float64) bool
- func EqualNearly(a, b float64) bool
- func GetMapFloat(data map[string]interface{}, key string) float64
- func GetMapVal[T any](items map[string]interface{}, key string, defVal T) T
- func HMAC(request []byte, secret []byte, algorithm func() hash.Hash, digest string) string
- func ISO8601(millis int64) string
- func IsNil(i interface{}) bool
- func MapValStr(input map[string]interface{}) map[string]string
- func OmitMapKeys(items map[string]interface{}, keys ...string)
- func ParseTimeFrame(timeframe string) (int, *errs.Error)
- func PopMapVal[T any](items map[string]interface{}, key string, defVal T) T
- func PrecFloat64(num float64, prec float64, isRound bool) (float64, error)
- func PrecFloat64Str(num float64, prec float64, isRound bool) (string, error)
- func PrecisionFromString(input string) float64
- func ReadFile(path string) ([]byte, error)
- func ReadJsonFile(path string, obj interface{}) error
- func SafeMapVal[T any](items map[string]string, key string, defVal T) (result T, err error)
- func SafeParams(params *map[string]interface{}) map[string]interface{}
- func SetFieldBy[T any](field *T, items map[string]interface{}, key string, defVal T)
- func Signature(data string, secret string, method string, hashName string, digest string) (string, *errs.Error)
- func UUID(length int) string
- func UrlEncodeMap(params map[string]interface{}, escape bool) string
- func WriteFile(path string, data []byte) error
- func WriteJsonFile(path string, data interface{}) error
- func YMD(timestamp int64, separator string, fullYear bool) string
Constants ¶
View Source
const ( PrecModeDecimalPlace = 2 PrecModeSignifDigits = 3 PrecModeTickSize = 4 )
View Source
const (
UriEncodeSafe = "~()*!.'"
)
Variables ¶
View Source
var ( ErrInvalidPrecision = errors.New("invalid precision") ErrNegPrecForTickSize = errors.New("negative precision for tick size") )
Functions ¶
func ArrContains ¶
func ArrContains[T comparable](s []T, e T) bool
func ByteToStruct ¶
ByteToStruct 将[]byte类型的chan通道,转为指定类型通道
func DecToPrec ¶
DecToPrec 将数字转换为指定精度返回
num: 需要处理的数字字符串 countMode: PrecModeDecimalPlace 保留小数点后指定位; PrecModeSignifDigits 保留全部有效数字个数 PrecModeTickSize 返回给定的数字的整数倍 precision: 结合countMode使用,正整数,负整数,正浮点数 isRound: 是否四舍五入,默认截断 padZero: 是否尾部填充0到指定长度
func EncodeToLatin1 ¶
func EncodeURIComponent ¶
func GetMapFloat ¶
func IsNil ¶
func IsNil(i interface{}) bool
IsNil 判断是否为nil
golang中类型和值是分开存储的,如果一个指针有类型,值为nil,直接判断==nil会返回false
func OmitMapKeys ¶
func PrecFloat64 ¶
PrecFloat64 对给定浮点数取近似值,精确到指定位数
func PrecisionFromString ¶
func ReadJsonFile ¶
func SafeMapVal ¶
SafeMapVal 从字典中读取给定键的值,并自动转换为需要的类型,如果出错则返回默认值
func SafeParams ¶
func SetFieldBy ¶
func Signature ¶
func Signature(data string, secret string, method string, hashName string, digest string) (string, *errs.Error)
Signature method: rsa, eddsa, hmac
hashName: rsa: sha256/sha384/sha512 eddsa: 不需要 hmac:sha256/sha384/sha512 digest: hmac: base64/hex
func UrlEncodeMap ¶
UrlEncodeMap 将map编码为url查询字符串 escape: 是否对键和值进行编码
func WriteJsonFile ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.