Categorygithub.com/issue9/rands/v2
modulepackage
2.1.0
Repository: https://github.com/issue9/rands.git
Documentation: pkg.go.dev

# README

rands Build Status license codecov Go Reference

rands 为一个随机字符串生成工具。

// 生成一个长度为 [8,10) 之间的随机字符串
str := rands.String(8, 10, []byte("1234567890abcdefg"))


// 生成一个带缓存功能的随机字符串生成器
r, err := rands.New(time.Now().Unix(), 100, 5, 7, []byte("asdfghijklmn"))
ctx,cancel := context.WithCancel(context.Background())
go r.Serve(ctx)
defer cancel()
str1 := r.String()
str2 := r.String()

安装

go get github.com/issue9/rands/v2

版权

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

# Functions

Alpha 返回所有的字母.
AlphaNumber [Alpha] + [Number].
AlphaNumberPunct [Alpha] + [Number] + [Punct].
Bytes 产生随机字符数组 其长度为[min, max),bs 所有的随机字符串从此处取。.
New 声明 [Rands] seed 随机种子,若为 0 表示使用当前时间作为随机种子。 bufferSize 缓存的随机字符串数量,若为 0,表示不缓存。.
Number 返回所有的数字.
Punct 返回所有的标点符号.
Seed 手动指定一个随机种子 默认情况下使用当前包初始化时的时间戳作为随机种子。 [Bytes] 和 [String] 依赖此项。但是 [Rands] 有专门的随机函数,不受此影响。.
String 产生一个随机字符串 其长度为[min, max),bs 可用的随机字符。.

# Structs

Rands 提供随机字符串的生成.