local-server/cmd/dkl-local-server/ulid.go
2019-02-01 18:28:08 +11:00

23 lines
343 B
Go

package main
import (
"io"
"math/rand"
"time"
ulidp "github.com/oklog/ulid"
)
var (
ulidCtx struct{ entropy io.Reader }
)
func initUlid() {
entropy := ulidp.Monotonic(rand.New(rand.NewSource(time.Now().UnixNano())), 0)
ulidCtx.entropy = entropy
}
func ulid() string {
return ulidp.MustNew(ulidp.Now(), ulidCtx.entropy).String()
}