util

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToStr

func BoolToStr(value bool) string

BoolToStr converts bool to string.

func ByteToStr

func ByteToStr(value byte) string

ByteToStr converts byte to string.

func Bytes2Length

func Bytes2Length(ret []byte) int64

Bytes2Length converts a byte array to an int64 value.

func DecodeBase64

func DecodeBase64(input string) ([]byte, error)

DecodeBase64 decode a base64 string.

func DecodeBase64Str

func DecodeBase64Str(input string) string

DecodeBase64Str decode a base64 string.

func DecodeHex

func DecodeHex(input string) ([]byte, error)

func EncodeBase64

func EncodeBase64(input string) string

---------------------------------------------------------- EncodeBase64 converts an input string to base64 string.

func EncodeHex

func EncodeHex(input []byte) string

----------------------------------------------------------

func FillPrefixToLen

func FillPrefixToLen(in, prefix string, length int) string

func Float32ToStr

func Float32ToStr(value float32) string

Float32ToStr converts float32 to string.

func Float32ToStrPrec2

func Float32ToStrPrec2(value float32) string

Float32ToStr converts float32 to string. Keep prec of 2

func Float64ToStr

func Float64ToStr(value float64) string

Float64ToStr converts float64 to string.

func Float64ToStrByPrec

func Float64ToStrByPrec(f float64, prec int) string

func Float64ToStrPrec2

func Float64ToStrPrec2(f float64) string

Float64ToStr converts float64 to string. Keep prec of 2

func GetCallerFuncName

func GetCallerFuncName(skip int) string

func GetExecFolder

func GetExecFolder() string

获取当前程序/可执行文件,所在的文件夹,的绝对路径

func GetExecName

func GetExecName() (n string)

func GetExecPath

func GetExecPath() string

获取当前程序/可执行文件,所在的绝对路径

func GetFuncName

func GetFuncName(i any) string

func HttpDo

func HttpDo(req *http.Request) (bodyBytes []byte, err error)

func Int8ToStr

func Int8ToStr(value int8) string

Int8ToStr converts int32 to string.

func Int16ToStr

func Int16ToStr(value int16) string

Int16ToStr converts int32 to string.

func Int32ListToStr

func Int32ListToStr(Int32List []int32, split string) string

---------------------------------------------------------- Int32ListToStr []int32 to string

func Int32ListToStrWithDelimiter

func Int32ListToStrWithDelimiter(Int32List []int32, split, left, right string) string

----------------------------------------------------------

func Int32ToStr

func Int32ToStr(value int32) string

Int32ToStr converts int32 to string.

func Int64ToStr

func Int64ToStr(value int64) string

Int64ToStr converts int64 to string.

func IntToStr

func IntToStr(value int) string

IntToStr converts int to string.

func InterfaceToInt32

func InterfaceToInt32(val any, defaultVal int32) int32

----------------------------------------------------------

func InterfaceToString

func InterfaceToString(val any, defaultVal string) string

func Length2Bytes

func Length2Bytes(len int64, buffer []byte) []byte

---------------------------------------------------------- Length2Bytes converts an int64 value to a byte array.

func NewHttpRequest

func NewHttpRequest(method, rawURL string, header, querys map[string]string, body string) (*http.Request, error)

func ReplaceByStringMap

func ReplaceByStringMap(str string, replaceMap map[string]string) string

根据替换映射表替换字符串,要注意map的数据,不要造成循环替换

func SliceIndex

func SliceIndex(x any, f func(i int) bool) int

func StrFirstToLower

func StrFirstToLower(str string) string

func StrFirstToUpper

func StrFirstToUpper(str string) string

func StrIdToLower

func StrIdToLower(str string) string

gorm-gen 工具生成的字段采用ID命名 protoc 工具生成的字段采用Id命名 使用起来依然太复杂,简单的代码替换难以分析是orm代码还是pb代码,干脆proto用ID命名就行了 本次代码提交,先保留调用,实现为空

func StrListToStr

func StrListToStr(stringList []string, split string) string

---------------------------------------------------------- StringListToStr []string to string

func StrListUnique

func StrListUnique(x []string) []string

func StrToBool

func StrToBool(value string) (bool, error)

StrToBool converts string to bool.

func StrToByte

func StrToByte(value string) (byte, error)

StrToByte converts string to byte.

func StrToCamelCase

func StrToCamelCase(str string) string

func StrToFloat32

func StrToFloat32(value string) (float32, error)

StrToFloat32 converts string to float32.

func StrToFloat64

func StrToFloat64(value string) (float64, error)

StrToFloat64 converts string to float64.

func StrToFloat64WithDefault

func StrToFloat64WithDefault(value string, d float64) float64

StrToFloat64 converts string to float64.

func StrToInt

func StrToInt(value string) (int, error)

StrToInt converts string to int.

func StrToInt8

func StrToInt8(value string) (int8, error)

StrToInt8 converts string to int8.

func StrToInt16

func StrToInt16(value string) (int16, error)

StrToInt16 converts string to int16.

func StrToInt32

func StrToInt32(value string) (int32, error)

StrToInt32 converts string to int32.

func StrToInt32List

func StrToInt32List(str string, split string) (ret []int32, err error)

StrToInt32List string to []int32

func StrToInt32List2

func StrToInt32List2(str, start, end, split string) ([]int32, error)

func StrToInt32ListWithDelimiter

func StrToInt32ListWithDelimiter(str, split, left, right string) (ret []int32, err error)

StrToInt32List string to []int32

func StrToInt32WithDefault

func StrToInt32WithDefault(value string, defaultVal int32) int32

StrToInt32 converts string to int32.

func StrToInt64

func StrToInt64(value string) (int64, error)

StrToInt64 converts string to int64.

func StrToInt64WithDefault

func StrToInt64WithDefault(value string, defaultVal int64) int64

StrToInt64 converts string to int64.

func StrToStrList

func StrToStrList(str string, split string) (ret []string)

StrToStringList string to []string, ignore empty string item

func StrToStrListByStartAndEnd

func StrToStrListByStartAndEnd(s string, splitStart string, splitEnd string) (ret []string)

func StrToStrListWithEmpty

func StrToStrListWithEmpty(str string, split string) (ret []string)

StrToStringList string to []string, include empty string item

func StrToStrListWithSplit

func StrToStrListWithSplit(str string, split string) (ret []string)

StrToStrList基础上,分割后不删除split字符

func StrToUint

func StrToUint(value string) (uint, error)

StrToInt converts string to int.

func StrToUint8

func StrToUint8(value string) (uint8, error)

StrToUint8 converts string to uint8.

func StrToUint16

func StrToUint16(value string) (uint16, error)

StrToUint16 converts string to int16.

func StrToUint32

func StrToUint32(value string) (uint32, error)

StrToUint32 converts string to uint32.

func StrToUint64

func StrToUint64(value string) (uint64, error)

StrToUint64 converts string to uint64.

func StrToUpperCamelCase

func StrToUpperCamelCase(s string) string

func TimeFromStr

func TimeFromStr(timeStr, format string) (time.Time, error)

func TimeFromStrDefault

func TimeFromStrDefault(timeStr string) (time.Time, error)

func TimeToStr

func TimeToStr(t time.Time, format string) string

func TimeToStrDefault

func TimeToStrDefault(t time.Time) string

func Uint8ToStr

func Uint8ToStr(value uint8) string

Uint8ToStr converts int32 to string.

func Uint16ToStr

func Uint16ToStr(value uint16) string

Uint16ToStr converts int32 to string.

func Uint32ToStr

func Uint32ToStr(value uint32) string

Uint32ToStr converts int32 to string.

func Uint64ToStr

func Uint64ToStr(value uint64) string

Uint64ToStr converts uint64 to string.

func UintToStr

func UintToStr(value uint) string

UintToStr converts int to string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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