Snowflake IDs Generator

Go package to generate and parse unique IDs based on Twitter's Snowflake algorithm.
Getting Started
Installing
go get github.com/smnvdev/snowflake
Simple Usage
package main
import (
"fmt"
"github.com/smnvdev/snowflake"
)
func main() {
machineID := 1
g, err := snowflake.NewGenerator(machineID)
if err != nil {
fmt.Println(err)
return
}
id := g.Next()
fmt.Println(id)
}
Parse ID
You can parse the ID to get the timestamp, machine ID, and sequence number using the Parse function of the generator.
Custom Epoch
This package uses the Twitter Epoch of 1288834974657 or Nov 04 2010 01:42:54 by default.
You can set your own epoch value by setting snowflake.SetEpochTime before creating a new generator.
Custom Machine ID
You can set your own machine ID by setting snowflake.SetMachineID before creating a new generator.
Custom Sequence Bits
You can set your own sequence bits by setting snowflake.SetSequenceBits before creating a new generator.