Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- "math/rand"
- "time"
- "github.com/oklog/ulid"
- )
- func main() {
- t := time.Now()
- // t := time.Unix(1000000, 0)
- entropy := ulid.Monotonic(rand.New(rand.NewSource(t.UnixNano())), 0)
- // entropy := rand.Reader
- // entropy := ulid.Monotonic(rand.Reader, 0)
- ids := make([]ulid.ULID, 10000)
- for i := range ids {
- ids[i] = ulid.MustNew(ulid.Timestamp(t), entropy)
- }
- seen := make(map[ulid.ULID]bool)
- for _, id := range ids {
- fmt.Println(id)
- if seen[id] {
- log.Fatal("dup")
- }
- seen[id] = true
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement