feat(id): defaultNewID via crypto/rand, injectable

This commit is contained in:
Hermes 2026-06-23 01:31:01 -07:00
parent 58a4e1db8f
commit 98ec0bba3d

14
id.go Normal file
View file

@ -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)
}