From 98ec0bba3d58c895052c93c4d1159f2adbc53125 Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 23 Jun 2026 01:31:01 -0700 Subject: [PATCH] feat(id): defaultNewID via crypto/rand, injectable --- id.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 id.go diff --git a/id.go b/id.go new file mode 100644 index 0000000..7841a8b --- /dev/null +++ b/id.go @@ -0,0 +1,14 @@ +package main + +import ( + "crypto/rand" + "encoding/hex" +) + +// NewID — production ID generator. 8 bytes crypto/rand -> 16 hex chars. +// Cheap and unique enough. In tests, replace via StoreOptions.NewID for determinism. +func NewID() string { + b := make([]byte, 8) + _, _ = rand.Read(b) + return hex.EncodeToString(b) +}