Skip to content

NeoyeElf/snowflake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snowflake

Forked from bwmarrin/snowflake

Installing

go get github.com/NeoyeElf/snowflake

Usage

Example Program:

package main

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

func main() {

	// Create a new Node with a Node number of 1
	node, err := snowflake.NewNode(1)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Generate a snowflake ID.
	id := node.Generate()

	// Print out the ID in a few different ways.
	fmt.Printf("Int64  ID: %d\n", id)
	fmt.Printf("Base2  ID: %s\n", id.Base2())
	fmt.Printf("Base64 ID: %s\n", id.Base64())
}

What's new

You can use custom NodeId Bits and Sequence ID Bits

node, err := snowflake.NewNode(1, WithCustomBits(8, 14))

About

A simple to use Go (golang) package to generate or parse Twitter snowflake IDs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%