module
Version:
v0.1.9
Opens a new window with list of versions in this module.
Published: Oct 13, 2025
License: Apache-2.0
Opens a new window with license information.
README
¶
Golang Safe Utils
Golang安全的操作函数
使用
// go get github.com/Bronya0/go-utils
// 按需导入
import(
"github.com/Bronya0/go-utils/fileutil"
"github.com/Bronya0/go-utils/strutil"
"github.com/Bronya0/go-utils/container"
"github.com/Bronya0/go-utils/convert"
"github.com/Bronya0/go-utils/timeutil"
"github.com/Bronya0/go-utils/uid"
"github.com/Bronya0/go-utils/validator"
...
)
函数说明
fileutil 包
SaveFile: 安全保存上传文件,包含文件类型和哈希值校验
HashReader: 对io.Reader进行流式哈希计算
HashBytes: 对字节切片进行流式哈希计算
HashFile: 对文件进行流式哈希计算
- 其他常用的
目录、文件函数
ZipFiles、UnzipSafe等: 安全压缩解压ZIP文件,防御路径遍历、解压炸弹等攻击
strutil 包
JoinStr: 高效字符串拼接,使用strings.Builder避免中间对象过多
container 包
NewSet: 创建set集合。提供了完善的操作API
validator 包
timeutil 包
convert 包
- 封装了常用的
类型转换函数
- 封装了常用的
单位转换函数
uid 包
- 封装了常用的
唯一ID生成函数,例如雪花ID、ULID
Directories
¶
Click to show internal directories.
Click to hide internal directories.