https://github.com/archishmansengupta/tinyid
A super tiny, <80 LoC, high performant fast Go unique string ID generator
https://github.com/archishmansengupta/tinyid
golang id-generator tinyid uuid
Last synced: about 1 year ago
JSON representation
A super tiny, <80 LoC, high performant fast Go unique string ID generator
- Host: GitHub
- URL: https://github.com/archishmansengupta/tinyid
- Owner: ArchishmanSengupta
- License: mit
- Created: 2024-03-03T15:03:21.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-03T17:07:13.000Z (over 2 years ago)
- Last Synced: 2025-02-09T11:11:31.024Z (over 1 year ago)
- Topics: golang, id-generator, tinyid, uuid
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## tinyid
A super tiny, high performant fast Go unique string ID generator:
- *Safe*: Utilizes cryptographically strong random APIs to ensure security.
- *Compact*: Employs a larger alphabet than UUID ```(A-Za-z0-9_-)```, potentially reducing ID size from 36 to 31.
- *Efficient*: Benchmarks at approximately ```489.3 ns/op``` for generating IDs.
- *100% TC*: Achieves full test coverage.
- *Small*: <80 LoC.
## Benchmark:
```
goos: darwin
goarch: arm64
pkg: github.com/ArchishmanSengupta/tinyid
BenchmarkNewTinyID-10 2419586 489.3 ns/op
BenchmarkGenerateTinyID-10 2457799 489.7 ns/op
PASS
ok github.com/ArchishmanSengupta/tinyid 3.535s
```
## Test Coverage:
```
go test -v
=== RUN TestGenerateTinyID
--- PASS: TestGenerateTinyID (0.00s)
=== RUN TestNewTinyID
--- PASS: TestNewTinyID (0.00s)
PASS
ok github.com/ArchishmanSengupta/tinyid 0.420s
```
## Use:
```go
id, err := tinyid.NewTinyID()
if err != nil {
fmt.Print("some problem")
}
fmt.Println("Generated ID:", id)
```