typeid-odin
July 31, 2026 ยท View on GitHub
An Odin implementation of TypeIDs
TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.
Installation
Clone the library into your project's lib directory:
git clone --branch v0.1.0 --depth 1 \
https://github.com/prnvbn/typeid-odin.git lib/type_id
to add it as a submodule:
git submodule add https://github.com/prnvbn/typeid-odin.git lib/type_id
git -C lib/type_id checkout v0.1.0
Usage
package main
import "core:crypto"
import "core:fmt"
import "core:os"
import "lib:type_id"
main :: proc() {
// UUIDv7 generation requires a cryptographically secure random generator
context.random_generator = crypto.random_generator()
// Generate a TypeID
tid, err := type_id.generate("user")
if err != nil {
fmt.eprintln("failed to generate TypeID:", type_id.error_string(err))
return
}
str := type_id.to_string(tid)
defer delete(str)
fmt.println(str)
// Read an existing TypeID
parsed, read_err := type_id.read("user_00041061050r3gg28a1c60t3gf")
assert(read_err == nil)
// Write without allocating a string
write_err := type_id.write(os.to_writer(os.stdout), parsed)
assert(write_err == nil)
fmt.println()
}
Map the lib collection when running or building your program:
odin run . -collection:lib=./lib