Documentation
¶
Index ¶
- Variables
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesDecryptFromBase64(b64 string, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func AesEncryptToBase64(origData, key []byte) (string, error)
- func AnyIsNil(val any) bool
- func AnyToInt32(val any, defaultVal int32) int32
- func AnyToStr(val any) string
- func BoolToStr(value bool) string
- func ByteToStr(value byte) string
- func Bytes2Length(ret []byte) int64
- func Conv_gb2312_utf8(s string) (string, error)
- func Conv_gbk2utf8(s string) (string, error)
- func Conv_utf16be_utf8(s string) (string, error)
- func Conv_utf16le_utf8(s string) (string, error)
- func Crc32(src string) (string, error)
- func DateFromStrDefault(dateStr string) (time.Time, error)
- func DateToStrDefault(t time.Time) string
- func DecodeBase64(input string) ([]byte, error)
- func DecodeBase64Str(input string) string
- func DecodeHex(input string) ([]byte, error)
- func EncodeBase64(input string) string
- func EncodeHex(input []byte) string
- func Exec(name string, args ...string) (string, error)
- func ExecBG(command string) errordeprecated
- func ExecSplit(command string) (string, error)
- func FillPrefixToLen(in, prefix string, length int) string
- func FixWinSlash(path string) string
- func Float32ToStr(value float32) string
- func Float32ToStrPrec2(value float32) string
- func Float64ToStr(value float64) string
- func Float64ToStrByPrec(f float64, prec int) string
- func Float64ToStrPrec2(f float64) string
- func GetCallerFuncName(skip int) string
- func GetCurDir() string
- func GetExecFolder() string
- func GetExecName() (n string)
- func GetExecPath() string
- func GetFileMd5(fi string) (string, error)
- func GetFileMd5Stream(f io.Reader) (string, error)
- func GetFuncBaseName(fn string) string
- func GetFuncName(i any) string
- func GetRand(start, end int) int
- func GetRandStr(n int) string
- func GetSha256(data []byte) string
- func GetTraceIdFromCtx(ctx context.Context) (string, bool)
- func GetUrlQueryString(req any) (querys map[string]string)
- func GetUserIdFromCtx(ctx context.Context) (int32, bool)
- func HmacSha256(data, secret string) []byte
- func HttpDo(req *http.Request) (bodyBytes []byte, err error)
- func Int8ToStr(value int8) string
- func Int16ToStr(value int16) string
- func Int32ListExcept(baseList []int32, exclude []int32) (ret []int32)
- func Int32ListIntersect(list1 []int32, list2 []int32) (ret []int32)
- func Int32ListSafeGet(list []int32, index int) (ret int32)
- func Int32ListToStr(Int32List []int32, split string) string
- func Int32ListToStrWithDelimiter(Int32List []int32, split, left, right string) string
- func Int32ListUnion(list1 []int32, list2 []int32) []int32
- func Int32ListUnique(list []int32) []int32
- func Int32ToStr(value int32) string
- func Int64ToStr(value int64) string
- func IntToStr(value int) string
- func IsFuncParamPB(f any) bool
- func IsPB(t reflect.Type) bool
- func Length2Bytes(len int64, buffer []byte) []byte
- func Md5Sum(input ...string) string
- func MessageToCleanString(msg proto.Message, str *string) error
- func MessageToString(msg proto.Message, str *string) error
- func NewHttpRequest(method, rawURL string, header, querys map[string]string, body string) (*http.Request, error)
- func NewHttpRequestJson(method, rawURL string, header, querys map[string]string, body any) (*http.Request, error)
- func NewPath(p string) *pathHelper
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func ReplaceByStringMap(str string, replaceMap map[string]string) string
- func RsaDecryptFromBase64(priKey *rsa.PrivateKey, encryptedMsg64 string) string
- func RsaEncryptToBase64(pubKey *rsa.PublicKey, msg string) string
- func RsaGetPriKey(priKeyBytes []byte) *rsa.PrivateKey
- func RsaGetPubKey(pubKeyBytes []byte) *rsa.PublicKey
- func SetTraceIdToCtx(ctx context.Context, traceId string) context.Context
- func SetUserIdToCtx(ctx context.Context, userId int32) context.Context
- func StrFirstToLower(str string) string
- func StrFirstToUpper(str string) string
- func StrListExcept(baseList []string, exclude []string) (ret []string)
- func StrListIntersect(list1 []string, list2 []string) (ret []string)
- func StrListSafeGet(list []string, index int) (ret string)
- func StrListToStr(stringList []string, split string) string
- func StrListUnion(list1 []string, list2 []string) []string
- func StrListUnique(list []string) []string
- func StrListXOR(list1 []string, list2 []string) (ret []string)
- func StrPrefixByNum(str string, num int) string
- func StrToBool(value string) (bool, error)
- func StrToByte(value string) (byte, error)
- func StrToCamelCase(str string) string
- func StrToFloat32(value string) (float32, error)
- func StrToFloat64(value string) (float64, error)
- func StrToFloat64WithDefault(value string, d float64) float64
- func StrToInt(value string) (int, error)
- func StrToInt8(value string) (int8, error)
- func StrToInt16(value string) (int16, error)
- func StrToInt32(value string) (int32, error)
- func StrToInt32List(str string, split string) (ret []int32, err error)
- func StrToInt32List2(str, start, end, split string) ([]int32, error)
- func StrToInt32ListWithDelimiter(str, split, left, right string) (ret []int32, err error)
- func StrToInt32WithDefault(value string, defaultVal int32) int32
- func StrToInt64(value string) (int64, error)
- func StrToInt64WithDefault(value string, defaultVal int64) int64
- func StrToStrList(str string, split string) (ret []string)
- func StrToStrListByStartAndEnd(s string, splitStart string, splitEnd string) (ret []string)
- func StrToStrListWithEmpty(str string, split string) (ret []string)
- func StrToStrListWithSplit(str string, split string) (ret []string)
- func StrToUint(value string) (uint, error)
- func StrToUint8(value string) (uint8, error)
- func StrToUint16(value string) (uint16, error)
- func StrToUint32(value string) (uint32, error)
- func StrToUint64(value string) (uint64, error)
- func StrToUpperCamelCase(s string) string
- func StringToMessage(str *string, msg proto.Message) error
- func TimeFromStr(timeStr, format string) (time.Time, error)
- func TimeFromStrDefault(timeStr string) (time.Time, error)
- func TimeToStr(t time.Time, format string) string
- func TimeToStrDefault(t time.Time) string
- func UUID() string
- func UUID_S() string
- func Uint8ToStr(value uint8) string
- func Uint16ToStr(value uint16) string
- func Uint32ToStr(value uint32) string
- func Uint64ToStr(value uint64) string
- func UintToStr(value uint) string
- func WalkSliceByStep(x any, step int, cb func(s, e int) error) (err error)
- type FileType
- type IDManager
Constants ¶
This section is empty.
Variables ¶
var DefaultIDMgr = NewIDManager(100000)
var Interact _interact
var PgoTraceIDKey = pgoTraceID{}
var PgoUserIDKey = pgoUserID{}
Functions ¶
func AesDecrypt ¶
func AesEncrypt ¶
func AesEncryptToBase64 ¶
func AnyToInt32 ¶ added in v0.0.6
--------------------------------------------------
func Bytes2Length ¶
Bytes2Length converts a byte array to an int64 value.
func Conv_gb2312_utf8 ¶ added in v0.0.6
func Conv_gbk2utf8 ¶ added in v0.0.6
func Conv_utf16be_utf8 ¶ added in v0.0.6
func Conv_utf16le_utf8 ¶ added in v0.0.6
func DateFromStrDefault ¶ added in v0.0.6
-------------------------------------------------- "YYYYMMDD"
func DecodeBase64 ¶
DecodeBase64 decode a base64 string.
func DecodeBase64Str ¶
DecodeBase64Str decode a base64 string.
func EncodeBase64 ¶
-------------------------------------------------- EncodeBase64 converts an input string to base64 string.
func FillPrefixToLen ¶
func FixWinSlash ¶ added in v0.0.6
FixWinSlash 将路径中的反斜杠替换为正斜杠,go能在win下正确使用正斜杠路径。 该函数可以处理整段文本,例如完整的 JSON 字符串。 特别的,保留每个连续的两字符反斜杠对 "\\\\"(通常表示 UNC/SMB 的开头), 但也需要注意路径中本来就拼接了双反斜杠的情况,比如C:\a\\b.txt。
func Float32ToStr ¶
Float32ToStr converts float32 to string.
func Float32ToStrPrec2 ¶
Float32ToStr converts float32 to string. Keep prec of 2
func Float64ToStr ¶
Float64ToStr converts float64 to string.
func Float64ToStrByPrec ¶
func Float64ToStrPrec2 ¶
Float64ToStr converts float64 to string. Keep prec of 2
func GetCallerFuncName ¶
func GetExecName ¶
func GetExecName() (n string)
func GetFileMd5Stream ¶
GetFileMd5Stream gets file's md5 by io.Reader
func GetFuncBaseName ¶ added in v0.0.6
func GetFuncName ¶
func GetRandStr ¶
func GetUrlQueryString ¶ added in v0.0.5
func HmacSha256 ¶
--------------------------------------------------
func Int32ListExcept ¶
差集:输出,baseList中有,exclude中没有,的元素
func Int32ListIntersect ¶
int32数组交集,输出排序是根据nums2的排序
func Int32ListSafeGet ¶ added in v0.0.6
func Int32ListToStr ¶
-------------------------------------------------- Int32ListToStr []int32 to string
func Int32ListToStrWithDelimiter ¶
--------------------------------------------------
func Int32ListUnion ¶
Int32ListUnion int32数组并集,去除重复数据
func IsFuncParamPB ¶ added in v0.0.5
--------------------------------------------------
func Length2Bytes ¶
-------------------------------------------------- Length2Bytes converts an int64 value to a byte array.
func Md5Sum ¶
-------------------------------------------------- Md5Sum calculates md5 value of some strings.
func MessageToCleanString ¶ added in v0.0.5
func NewHttpRequest ¶
func NewHttpRequestJson ¶
func PKCS7Padding ¶
func PKCS7UnPadding ¶
func ReplaceByStringMap ¶
根据替换映射表替换字符串,要注意map的数据,不要造成循环替换
func RsaDecryptFromBase64 ¶
func RsaDecryptFromBase64(priKey *rsa.PrivateKey, encryptedMsg64 string) string
func RsaGetPriKey ¶
func RsaGetPriKey(priKeyBytes []byte) *rsa.PrivateKey
func RsaGetPubKey ¶
func SetTraceIdToCtx ¶ added in v0.0.6
func SetUserIdToCtx ¶ added in v0.0.6
func StrFirstToLower ¶
func StrFirstToUpper ¶
func StrListExcept ¶
差集:输出,baseList中有,exclude中没有,的元素
func StrListIntersect ¶ added in v0.0.6
func StrListSafeGet ¶ added in v0.0.6
func StrListToStr ¶
-------------------------------------------------- StringListToStr []string to string
func StrListUnion ¶
StrListUnion string数组并集,去除重复数据
func StrListXOR ¶
取名XOR异或,实际逻辑是(A-B)U(B-A)的集合b https://www.lodashjs.com/docs/lodash.xor
func StrPrefixByNum ¶ added in v0.0.6
func StrToCamelCase ¶
func StrToFloat32 ¶
StrToFloat32 converts string to float32.
func StrToFloat64 ¶
StrToFloat64 converts string to float64.
func StrToFloat64WithDefault ¶
StrToFloat64 converts string to float64.
func StrToInt32List ¶
StrToInt32List string to []int32
func StrToInt32List2 ¶
func StrToInt32ListWithDelimiter ¶
StrToInt32List string to []int32
func StrToInt32WithDefault ¶
StrToInt32 converts string to int32.
func StrToInt64WithDefault ¶
StrToInt64 converts string to int64.
func StrToStrList ¶
StrToStringList string to []string, ignore empty string item
func StrToStrListWithEmpty ¶
StrToStringList string to []string, include empty string item
func StrToStrListWithSplit ¶
StrToStrList基础上,分割后不删除split字符
func StrToUint16 ¶
StrToUint16 converts string to int16.
func StrToUint32 ¶
StrToUint32 converts string to uint32.
func StrToUint64 ¶
StrToUint64 converts string to uint64.
func StrToUpperCamelCase ¶
func StringToMessage ¶ added in v0.0.5
--------------------------------------------------
func TimeFromStr ¶
-------------------------------------------------- format sample: "YYYYMMDDTHH:mm:ss"
func TimeFromStrDefault ¶
-------------------------------------------------- "YYYYMMDDTHH:mm:ss"
Types ¶
type IDManager ¶ added in v0.0.5
type IDManager struct {
// contains filtered or unexported fields
}
func NewIDManager ¶ added in v0.0.5
func (*IDManager) GetNewSmallestAndUniqueID ¶ added in v0.0.5
获取最小但不重复的ID