Created
November 16, 2017 21:32
-
-
Save technosophos/66668d9a7397da16aa1ce130607009ab to your computer and use it in GitHub Desktop.
Generate a ULID on the commandline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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