Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
yitter 9c34748c52 | 3 years ago | |
---|---|---|
.. | ||
source | 3 years ago | |
README.md | 3 years ago |
项目更多介绍参照:https://github.com/yitter/idgenerator
1.SDK,go1.14
2.启用 Go-Modules
go env -w GO111MODULE=on
# Next *ONLY* for China-Users:
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
go get -u -v github.com/yitter/idgenerator-go
// 定义参数
var options = idgen.NewIdGeneratorOptions(1) // 构造函数输入 WorkerId
// options.WorkerId = 1
// options.WorkerIdBitLength = 6
// options.SeqBitLength = 6
// ... 以上参数一般不需要设置,系统有默认值
idgen.SetIdGenerator(options)
// 调用方法生成Id
var id = idgen.NextId()
guoyahao | amuluowin | houseme
雪花算法中非常好用的数字ID生成器
C C# Pascal Go D other