go-utils

module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: Apache-2.0

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: 对文件进行流式哈希计算
  • 其他常用的目录、文件函数
  • ZipFilesUnzipSafe等: 安全压缩解压ZIP文件,防御路径遍历、解压炸弹等攻击
strutil 包
  • JoinStr: 高效字符串拼接,使用strings.Builder避免中间对象过多
container 包
  • NewSet: 创建set集合。提供了完善的操作API
validator 包
  • 提供了常用的高性能、准确的校验函数
timeutil 包
  • 提供了常用的日期时间解析、转换函数
convert 包
  • 封装了常用的类型转换函数
  • 封装了常用的单位转换函数
uid 包
  • 封装了常用的唯一ID生成函数,例如雪花IDULID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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