sdming / gosnow

snowflake in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gosnow

gosnow is a snowflake implementation in golang.

This is a fork of the upstream that replaces the the usage of panic() by returning errors instead.

package main

import (
    "github.com/sdming/gosnow"
    "fmt"
)

func main() {

    v, err := gosnow.Default()
    
    // Alternatively you can set the worker id if you are running multiple snowflakes
    // v, err := gosnow.NewSnowFlake(100)
    
    for i := 0; i < 10; i++ {
        id, err := v.Next()
        fmt.Println(id)
    }
}

About

snowflake in golang


Languages

Language:Go 100.0%