Skip to content

Instantly share code, notes, and snippets.

@technosophos
Created November 16, 2017 21:32
Show Gist options
  • Save technosophos/66668d9a7397da16aa1ce130607009ab to your computer and use it in GitHub Desktop.
Save technosophos/66668d9a7397da16aa1ce130607009ab to your computer and use it in GitHub Desktop.
Generate a ULID on the commandline
package main
import (
"fmt"
"math/rand"
"strings"
"time"
"github.com/oklog/ulid"
)
func main() {
t := time.Now()
entropy := rand.New(rand.NewSource(t.UnixNano()))
fmt.Println(strings.ToLower(ulid.MustNew(ulid.Timestamp(t), entropy).String()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment