Uuid
UUID generator for Go
Install / Use
/learn @skeeto/UuidREADME
UUID generator for Go
This package generates version 4 UUIDs (RFC 4122). It's 35 times faster than other UUID libraries (1, 2), and, unlike those libraries, cannot fail to generate a UUID.
BenchmarkSelf-8 100000000 13.4 ns/op
BenchmarkGofrs-8 2000000 623 ns/op
BenchmarkGoogle-8 2000000 627 ns/op
It's faster and more reliable because it generates UUIDs from an internal CSPRNG. Operating system entropy is only used to seed the generator once. Other libraries read 16 bytes of operating system entropy for each UUID, which is why they're slower and can fail.
API documentation: https://pkg.go.dev/nullprogram.com/x/uuid
Example usage
package main
import (
"flag"
"fmt"
"nullprogram.com/x/uuid"
)
func main() {
n := flag.Int("n", 1, "number of UUIDs to generate")
flag.Parse()
g := uuid.NewGen()
for i := 0; i < *n; i++ {
fmt.Println(g.NewV4())
}
}
Result:
$ ./example -n 4
66ccddf3-be66-455d-8bab-13a20cf57d05
17e7e09c-fafd-4482-999c-7fbd87a1e7a8
b7146884-9678-435e-b76e-9fc8407544e7
cc6f0bf7-9762-456c-890a-3213c6965e95
Related Skills
node-connect
347.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
