Skip to content

issue9/unique

Repository files navigation

unique Build Status license codecov Go Reference

用于生成一个唯一字符串

// 生成由数字和字母组成的唯一字符串,比如 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() // 生成唯一字符串。

安装

go get github.com/issue9/unique/v2

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。