repository
0.0.0-20240704085122-2497df1093b7
Repository: https://github.com/tangzhangming/tools.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# README
Golang 工具包
字符串 Str
函数 | 说明 |
---|---|
Random(length uint) string | 生成随机字符串 |
Kebab(s string) string | 将字符串转换为 烤串式( kebab-case ) 表示方法 |
Camel(s string) string | 将指定字符串转换为 驼峰式 表示方法 |
Snake(s string) string | 将驼峰的函数名或者字符串转换成下划线_命名的函数或者字符串 |
数字 Number
函数 | 说明 |
---|---|
ForHumans(number interface{}, precision int, abbreviate bool) string | 返回所提供数值的人类可读格式, 例如: 1020000 => 1.02 billion |
Abbreviate(number interface{}, precision int) string | ForHumans的小写版, 例如: 15000=>15K |
FileSize(bytes int64, precision int) | 给定字节值作为字符串返回文件大小表示如1.05GB |
Clamp(number interface{}, min interface{}, max interface{}) interface{} | 确保给定数字保持在指定范围内 |