A library for creating Snowflake identifiers in Go. Snowflakes are 64 bit identifiers that are guaranteed to be unique across all processes and machines for a given time interval. They are comprised of:
- 41 bits for time in milliseconds (gives us 69 years with a custom epoch)
- 10 bits for a machine id (gives us up to 1024 machines)
- 12 bits of sequence (in case more than one identifier is requested in the same millisecond)
package main
import (
"fmt"
"github.com/greenygh0st/snowflake"
)
node := snowflake.NewSnowflake(1, 1)
id := node.Generate()