Fast ID generator based on timestamp, sequence number and worker id.
Generating IDs quickly is a common task. Making this quickly is a nice thing to have.
- Simple.
- Thread-safe.
- Time based.
- Dependency-free.
go get github.com/cristalhq/fastid
gen, err := NewGenerator(100, 200)
id := gen.Next()
ts, seq, w := id.Parts()
ts = id.Timestamp()
seq = id.Sequence()
w = id.WorkerID()
See these docs.