service.xpcool.com/common/tools/random/random.go
夏犀麟 8d5f2c65ae feat(common): 新增公共模块 common/tools 及项目上下文记忆体系
- common/tools 工具模块,10 个子功能:md5/cryptox/uuid/random/timex/convertx/strx/slicex/ip/filex(薄封装 GoFrame 内置组件)
- AGENTS.md 项目智能体说明书(架构、规范、命令、记忆体系索引)
- docs/change-log/2026-08-24.md 本次请求与变更记录
- .gitignore 排除 .workbuddy/;PROJECT_STRUCTURE.md 补充目录树
2026-08-24 17:18:10 +08:00

27 lines
598 B
Go

// Package random provides random number and string generation helpers.
package random
import (
"github.com/gogf/gf/v2/util/grand"
)
// Int returns a random integer in [min, max].
func Int(min, max int) int {
return grand.N(min, max)
}
// String returns a random alphanumeric string of length n.
func String(n int) string {
return grand.S(n)
}
// Digits returns a random numeric-only string of length n, e.g. SMS codes.
func Digits(n int) string {
return grand.Digits(n)
}
// Letters returns a random letter-only string of length n.
func Letters(n int) string {
return grand.Letters(n)
}