- 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 补充目录树
22 lines
451 B
Go
22 lines
451 B
Go
// Package uuid provides unique ID generation helpers.
|
|
package uuid
|
|
|
|
import (
|
|
"github.com/gogf/gf/v2/util/grand"
|
|
"github.com/gogf/gf/v2/util/guid"
|
|
)
|
|
|
|
// New returns a 32-character unique ID without dashes.
|
|
func New() string {
|
|
return guid.S()
|
|
}
|
|
|
|
// Short returns a random alphanumeric ID of length n (defaults to 8 when n <= 0).
|
|
// Suitable for short invite codes / trace ids.
|
|
func Short(n int) string {
|
|
if n <= 0 {
|
|
n = 8
|
|
}
|
|
return grand.S(n)
|
|
}
|