nyaa8 / gemshards

πŸ’Ž Snowflake-like Unique ID generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snowflake-like Unique ID generator

Usage

Arguments:

  • EpochOffset 5730518316208800 (example) Epoch offset in microseconds (should remain consistent in all instances)
  • GemID 0-15 (default config) Must be unique across generator instances; otherwise, IDs can duplicate!

Example code:

package main

import (
	"fmt"

	"pkg.nyaa.science/gemshards"
)

func main() {
	generator := gemshards.Gem{EpochOffset: 5730518316208800, GemID: 0}
	shard := generator.Generate()
	fmt.Println("Unique ID:", shard.ID)
}

πŸ™Œ Contributing

Please write commit messages according to Chris Beams' guide 😊

Thank you very much for reading this πŸ™‡πŸΌβ€β™€οΈ

About

πŸ’Ž Snowflake-like Unique ID generator


Languages

Language:Go 100.0%