# go-snowflake **Repository Path**: misaka-0x0d/gosnowflake ## Basic Information - **Project Name**: go-snowflake - **Description**: Go 版分布式系统生成唯一ID算法(Snowflake) - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-15 - **Last Updated**: 2022-06-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-snowflake #### 介绍 Go 版分布式系统生成唯一ID算法(Snowflake) #### download ```shell go get gitee.com/lingdun/gosnowflake ``` #### example ```go package main import ( "fmt" "gitee.com/misaka-0x0d/gosnowflake" ) func main() { twepoc := int64(1585644268888) datacenterId := 1 workerId := 1 err, id := gosnowflake.NewIdWorker(workerId, datacenterId, twepoc) if err != nil { panic(err) } if err, id := id.NextId(); err == nil { fmt.Printf("gen id: %d", id) }else { panic(err) } } ```