- Notifications
You must be signed in to change notification settings - Fork10
Go implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
License
jetify-com/typeid-go
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A golang implementation ofTypeIDs
TypeIDs are a modern,type-safe, globally unique identifier based on the upcomingUUIDv7 standard. They provide a ton of nice properties that make them a great choiceas the primary identifiers for your data in a database, APIs, and distributed systems.Read more about TypeIDs in theirspec.
This particular implementation provides a go library for generating and parsing TypeIDs.
To add this library as a dependency in your go module, run:
go get go.jetify.com/typeid/v2
This library provides a go implementation of TypeID:
import ("go.jetify.com/typeid/v2")funcexample() {// Generate a new TypeID with a prefix (panics on invalid prefix)tid:=typeid.MustGenerate("user")fmt.Println(tid)// Generate a new TypeID without a prefixtid=typeid.MustGenerate("")fmt.Println(tid)// Generate with error handlingtid,err:=typeid.Generate("user")iferr!=nil {log.Fatal(err) }// Parse an existing TypeIDtid,_=typeid.Parse("user_00041061050r3gg28a1c60t3gf")fmt.Println(tid)// Convert from UUIDtid,_=typeid.FromUUID("user","018e5f71-6f04-7c5c-8123-456789abcdef")fmt.Println(tid)}
For the full documentation, see this package'sgodoc.
About
Go implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.