Skip to content

A super tiny, <80 LoC, high performant fast Go unique string ID generator

License

Notifications You must be signed in to change notification settings

ArchishmanSengupta/tinyid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

id, err := tinyid.NewTinyID()
	if err != nil {
		fmt.Print("some problem")
}
fmt.Println("Generated ID:", id)

About

A super tiny, <80 LoC, high performant fast Go unique string ID generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages