Skip to content

Instantly share code, notes, and snippets.

@indigofeather
Created December 27, 2017 15:46
Show Gist options
  • Save indigofeather/604cf651cbe9d4d2b4603fc0f2e8c15c to your computer and use it in GitHub Desktop.
Save indigofeather/604cf651cbe9d4d2b4603fc0f2e8c15c to your computer and use it in GitHub Desktop.
snowflake
package main
import (
"log"
"sync"
"github.com/bwmarrin/snowflake"
)
var wg sync.WaitGroup
func main() {
node, err := snowflake.NewNode(1)
if err != nil {
panic(err)
}
log.Println("go")
for i := 0; i <= 10; i++ {
wg.Add(1)
go func() {
println(node.Generate().Int64())
wg.Done()
}()
}
wg.Wait()
log.Println("exit")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment