Skip to content

Repository files navigation

NULID

CI

nulid is a dependency-free Go implementation of NULID, a 128-bit lexicographically sortable identifier. It is a nanosecond-resolution descendant of ULID: while a ULID carries a 48-bit millisecond timestamp, a NULID carries a 68-bit nanosecond timestamp. That gives you much tighter ordering when you're generating IDs at high throughput, but it still keeps the same 128-bit / 26-character footprint.

Install

go get github.com/yzevm/nulid

Usage

import "github.com/yzevm/nulid"

func main() {
	id := nulid.Make()         // crypto/rand entropy, current time
	fmt.Println((id.String())) // e.g. 01H1CD7M59WM8N000000000C1S

	fmt.Println(id.Random()) // 60-bit random component
	fmt.Println(id.Time())   // time.Time, full precision
}

About

Nanosecond-precision Universally Lexicographically Sortable Identifier in Golang

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages