https://github.com/issue9/unique
产生唯一字符串
https://github.com/issue9/unique
go golang unique unique-id uniqueid
Last synced: 4 months ago
JSON representation
产生唯一字符串
- Host: GitHub
- URL: https://github.com/issue9/unique
- Owner: issue9
- License: mit
- Created: 2017-08-23T16:36:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-02-12T18:48:51.000Z (over 1 year ago)
- Last Synced: 2025-02-12T19:42:24.885Z (over 1 year ago)
- Topics: go, golang, unique, unique-id, uniqueid
- Language: Go
- Homepage: https://pkg.go.dev/github.com/issue9/unique/v2
- Size: 49.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
unique
[](https://actions-badge.atrox.dev/issue9/unique/goto?ref=master)
[](https://opensource.org/licenses/MIT)
[](https://codecov.io/gh/issue9/unique)
[](https://pkg.go.dev/github.com/issue9/unique/v2)
======
用于生成一个唯一字符串
```go
// 生成由数字和字母组成的唯一字符串,比如 p4k5f81
u := unique.NewString(10)
go u.Serve(context.Background())
u.String()
// 生成由数字组成的唯一字符串,比如 15193130121
u := unique.NewNumber(10)
go u.Serve(context.Background())
u.String()
// 生成由日期与数字组成的唯一字符串,比如 20180222232332-1
u := unique.NewDate(10)
go u.Serve(context.Background())
u.String()
// 或者可以自定义一个 Unique 实例
u := unique.New(10, time.Second, "20060102150405-", 10)
go u.Serve(context.Background())
u.String() // 生成唯一字符串。
```
安装
---
```shell
go get github.com/issue9/unique/v2
```
版权
----
本项目采用 [MIT](https://opensource.org/licenses/MIT) 开源授权许可证,完整的授权说明可在 [LICENSE](LICENSE) 文件中找到。