项目更多介绍参照:https://github.com/yitter/idgenerator
1.SDK,go1.14
2.启用 Go-Modules
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
go get -u -v github.com/yitter/idgenerator-go
或 go.mod 中添加引用
require github.com/yitter/idgenerator-go v1.2.0
// 定义参数
var options = idgen.NewIdGeneratorOptions(1)
options.WorkerId = 1
options.WorkerIdBitLength = 6
options.SeqBitLength = 6
// ...
idgen.SetIdGenerator(options)
// 调用方法生成Id
var id = idgen.NextId()
guoyahao | amuluowin | houseme