Documentation
¶
Index ¶
- Constants
- func BoolToInt(b bool) int
- func Float64ToStr(f float64, prec int) string
- func HumanBandwidth(bytesPerSec int64) string
- func HumanBytes(size int64) string
- func HumanDuration(d time.Duration) string
- func Int64ToStr(i int64) string
- func IntToBool(i int) bool
- func IntToStr(i int) string
- func IntsToStrings(arr []int) []string
- func JSONToMapStrAny(s string) (map[string]any, error)
- func MapStrAnyToJSON(m map[string]any) (string, error)
- func MustStrToInt(s string) int
- func ParseBytes(s string) (int64, error)
- func StrToBool(s string) (bool, error)
- func StrToFloat64(s string) (float64, error)
- func StrToInt(s string) (int, error)
- func StrToInt64(s string) (int64, error)
- func StrToUint64(s string) (uint64, error)
- func StringsToInts(arr []string) ([]int, error)
- func ToInt64(v interface{}) (int64, error)
- func ToString(v interface{}) string
Constants ¶
View Source
const ( KB = 1024 MB = KB * 1024 GB = MB * 1024 TB = GB * 1024 PB = TB * 1024 )
常用字节单位(IEC标准, 1024 进制)
Variables ¶
This section is empty.
Functions ¶
func HumanBandwidth ¶
HumanBandwidth 将字节/秒 转换为 Mbps, Gbps 等 网络流量速率转换 (适用于带宽、速率显示,如 Mbps、MB/s) 例如: 125000 -> "1.00 Mbps" (≈125 KB/s)
func HumanDuration ¶
HumanDuration 将时间间隔格式化为可读字符串 例如: 90s -> "1m30s"
func Int64ToStr ¶
func JSONToMapStrAny ¶
JSONToMapStrAny 转换 JSON -> map[string]any
func MapStrAnyToJSON ¶
MapStrAnyToJSON 转换 map[string]any -> JSON 字符串
func ParseBytes ¶
ParseBytes 将带单位的字符串转为字节数 支持: B, KB, MB, GB, TB, PB (不区分大小写) 例如: "1.5GB" -> 1610612736
func StrToFloat64 ¶
func StrToInt64 ¶
func StrToUint64 ¶
func StringsToInts ¶
StringsToInts []string -> []int
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.