Skip to content

A basic library for generating Snowflake like IDs in Go.

License

Notifications You must be signed in to change notification settings

greenygh0st/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snowflake

Build CodeQL

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)

Usage

Importing

package main

import (
    "fmt"
    "github.com/greenygh0st/snowflake"
)

Usage

node := snowflake.NewSnowflake(1, 1)
id := node.Generate()

About

A basic library for generating Snowflake like IDs in Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages