conv

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToString

func AnyToString[T any](v T) string

AnyToString 会根据类型优化常见路径,其他走 fmt.Sprintf 使用泛型支持任意类型到字符串的转换

func BoolToStr

func BoolToStr(v bool) string

BoolToStr 将布尔值转换为字符串("true"或"false")

func BytesToHex

func BytesToHex(b []byte) string

BytesToHex 将字节数组转换为十六进制字符串

func FloatToStr

func FloatToStr(v float64, prec int) string

FloatToStr 将浮点数转换为字符串 prec 参数指定小数点后保留的位数

func HexToBytes

func HexToBytes(s string) ([]byte, error)

HexToBytes 将十六进制字符串解析为字节数组

func Int64ToStr

func Int64ToStr(v int64) string

Int64ToStr 将64位整数转换为字符串

func IntToStr

func IntToStr(v int) string

IntToStr 将整数转换为字符串

func StrToBool

func StrToBool(s string) (bool, error)

StrToBool 将字符串解析为布尔值 支持的字符串: "true", "false", "1", "0", "t", "f", "TRUE", "FALSE"等

func StrToFloat

func StrToFloat(s string) (float64, error)

StrToFloat 将字符串解析为浮点数

func StrToInt

func StrToInt(s string) (int, error)

StrToInt 将字符串解析为整数

func StrToInt64

func StrToInt64(s string) (int64, error)

StrToInt64 将字符串解析为64位整数

func StrToUint64

func StrToUint64(s string) (uint64, error)

StrToUint64 将字符串解析为64位无符号整数

func Uint64ToStr

func Uint64ToStr(v uint64) string

Uint64ToStr 将64位无符号整数转换为字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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