🆔 YAID-go
Go implementation of Yet Another ID
Install library
go get github.com/hnz/yaid/yaid-go
copy success
Usage
package main
import (
"fmt"
"github.com/hnz/yaid/yaid-go"
)
func main() {
id, err := yaid.New([]byte{123})
fmt.Println(id, err)
}
copy success
See full api specifications and examples here.
Command line
This package comes with a commandline utility called yaid
.
You can install it by running go install github.com/hnz/yaid/yaid-go/cmd
.
yaid 4X85VYWZC9ABP
copy success
Set metadata
yaid -m 123 4X85W9A0Y9TQP
copy success
Show info
yaid -i 4X85W9A0Y9TQP Time: 2023-07-05 01:31:57.440000 Meta: 123
copy success
Benchmark vs other implementations
goos: windows goarch: amd64 pkg: github.com/hnz/yaid cpu: AMD Ryzen 7 3700X 8-Core Processor BenchmarkYAID-16 5198966 231.2 ns/op 76 B/op 4 allocs/op BenchmarkYAIDGenerator-16 7151988 168.3 ns/op 26 B/op 2 allocs/op BenchmarkUUIDv1-16 38715171 30.42 ns/op 0 B/op 0 allocs/op BenchmarkUUIDv4-16 6573123 180.4 ns/op 40 B/op 2 allocs/op BenchmarkULID-16 6184029 193.5 ns/op 40 B/op 2 allocs/op
copy success
Develop
Build
go build -o yaid ./cmd
copy success
Lint
golint .
copy success
Test
go test
copy success