This repository has been archived by the owner. It is now read-only.
Universally Unique Lexicographically Sortable Identifier (ULID) in Go - Please use https://github.com/oklog/ulid
Go
Switch branches/tags
Nothing to show
Clone or download
Latest commit aeb52bf Jan 16, 2018
Permalink
Failed to load latest commit information.
.gitignore Initial commit Aug 1, 2016
LICENSE Badges, badges everywhere Aug 4, 2016
README.md Archiving repository Jan 16, 2018
ulid.go golint Aug 5, 2016
ulid_test.go Optimized replacing copy() for bytes swapping Aug 4, 2016

README.md

Universally Unique Lexicographically Sortable Identifier

Project status Go Report Card GoDoc MIT licensed

alizain/ulid port to Golang (binary format implemented).

Why ULID?

Check out ULID's README.

About this implementation

Important: this repository has been archived. Please use oklog/ulid implementation.

I ported it to see how fast would be the same algorithm in Go. Also, it is cryptographically secure using crypto/rand.

Installation

go get github.com/imdario/go-ulid

Usage

import (
    "github.com/imdario/go-ulid"
)

// ...

u := ulid.New()

Performance

On a Intel Core 2 Duo 6600 @ 2.40 GHz, Windows 10 and Go 1.6.3:

BenchmarkULID-2                  1000000              1029 ns/op              16 B/op          1 allocs/op
BenchmarkEncodedULID-2           1000000              1249 ns/op              48 B/op          2 allocs/op
BenchmarkSingleEncodedULID-2    10000000               206 ns/op              32 B/op          1 allocs/op

Approx. 800.640 op/s, 46 times faster than Javascript original implementation.

How does it compare to UUID?

Using google/uuid:

BenchmarkUUID-2                  1000000              1041 ns/op              16 B/op          1 allocs/op
BenchmarkEncodedUUID-2           1000000              1407 ns/op              64 B/op          2 allocs/op
BenchmarkSingleEncodedUUID-2     5000000               302 ns/op              48 B/op          1 allocs/op

go-ulid is about 12% faster than Google's UUID!