Created
December 27, 2017 15:46
-
-
Save indigofeather/604cf651cbe9d4d2b4603fc0f2e8c15c to your computer and use it in GitHub Desktop.
snowflake
This file contains 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 ( | |
"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