31 lines
1.2 KiB
Markdown
31 lines
1.2 KiB
Markdown
|
# ULID
|
||
|
|
||
|
```sh
|
||
|
go get git.wisellama.rocks/Wisellama/ulid@v0.0.1
|
||
|
```
|
||
|
|
||
|
ULIDs are universally unique lexico-graphically sortable
|
||
|
identifiers. They fit in the same 128-bits as a UUID, except that
|
||
|
instead of being pure random or using some hardware information, they
|
||
|
tag on a timestamp on the front. This makes them random but sortable
|
||
|
which is useful when using them for database IDs. Databases can
|
||
|
pre-load chunks of IDs that it assumes will be used. Fully random IDs
|
||
|
would break this caching functionality, but sortable random IDs will
|
||
|
keep the performance benefits.
|
||
|
|
||
|
This is Wisellama's implementation of a ULID library following the spec:
|
||
|
https://git.wisellama.rocks/Mirrors/ulid-spec
|
||
|
|
||
|
I was inspired by oklog's ULID library, and I used it to verify my
|
||
|
implementation was working correctly. I use this library in production
|
||
|
at work, so I highly recommend it.
|
||
|
https://github.com/oklog/ulid
|
||
|
|
||
|
I did not implement the full spec, and I'm sure I'm missing features
|
||
|
that are available in the oklog repo. However, I wanted to implement
|
||
|
ULIDs myself to support the features I use regularly. I don't like
|
||
|
adding unnecessary dependencies, so if there's something easy enough
|
||
|
that I can implement myself, I will most likely attempt to do so.
|
||
|
|
||
|
See the examples directory for usage.
|