1
0
mirror of synced 2026-02-27 15:27:55 +08:00
Files
SnowFlake-IdGenerator/Go/README.md
2021-04-02 23:37:02 +08:00

44 lines
810 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ❄️ idenerator-go
## 介绍
项目更多介绍参照https://github.com/yitter/idgenerator
## Go环境
1.SDKgo1.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
```
3. 安装方式
```
go get -u -v github.com/yitter/idgenerator-go
```
## 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