A simple-to-use Go (golang) package to generate or parse Twitter snowflake IDs. You can alter the number of bits used for the node id and step number (sequence) by setting the snowflake.NodeBits and snowflake.StepBits values. Remember that There is a maximum of 22 bits available that can be shared between these two values. You do not have to use all 22 bits. By default this package uses the Twitter Epoch of 1288834974657 or Nov 04 2010 01:42:54. You can set your own epoch value by setting snowflake. Epoch to a time in milliseconds to use as the epoch. When setting custom epoch or bit values you need to set them prior to calling any functions on the snowflake package, including NewNode(). Otherwise, the custom values you set will not be applied correctly. Import the package into your project then construct a new snowflake Node using a unique node number. The default settings permit a node number range from 0 to 1023.

Features

  • A very simple Twitter snowflake generator
  • Methods to parse existing snowflake IDs
  • Methods to convert a snowflake ID into several other data types and back
  • JSON Marshal/Unmarshal functions to easily use snowflake IDs within a JSON API
  • Monotonic Clock calculations protect from clock drift
  • The ID as a whole is a 63 bit integer stored in an int64

Project Samples

Project Activity

See All Activity >

Categories

Frameworks

License

BSD License

Follow snowflake for Go

snowflake for Go Web Site

Other Useful Business Software
Top Corporate LMS for Training | Best Learning Management Software Icon
Top Corporate LMS for Training | Best Learning Management Software

Deliver and Track Online Training and Stay Compliant - with Axis LMS!

Axis LMS enables you to deliver online and virtual learning and training through a scalable, easy-to-use LMS that is designed to enhance your training, automate your workflows, engage your learners and keep you compliant.
Learn More
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of snowflake for Go!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Go

Related Categories

Go Frameworks

Registered

2023-01-23