main.go 323 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/bwmarrin/snowflake"
  5. )
  6. func main() {
  7. // Create a new Node with a Node number of 1
  8. node, err := snowflake.NewNode(1)
  9. if err != nil {
  10. fmt.Println(err)
  11. return
  12. }
  13. // Generate a snowflake ID.
  14. id := node.Generate()
  15. json, _ := id.MarshalJSON()
  16. fmt.Println(string(json))
  17. }