Documentation
¶
Overview ¶
Package rands 生成各种随机字符串
// 生成一个长度介于 [6,9) 之间的随机字符串 str := rands.String(6, 9, []byte("1343567")) // 生成一个带缓存功能的随机字符串生成器 r := rands.New(nil, 100, 5, 7, []byte("adbcdefgadf;dfe1334")) ctx,cancel := context.WithCancel(context.Background()) go r.Serve(ctx) defer cancel() str1 := r.String() str2 := r.String()
NOTE: 仅是随机字符串,不保证唯一性。
Index ¶
- func Alpha() []byte
- func AlphaNumber() []byte
- func AlphaNumberPunct() []byte
- func Append[T Char](buf []byte, min, max int, bs []T) []byte
- func Bytes[T Char](min, max int, bs []T) []byte
- func LowerAlpha() []byte
- func Number() []byte
- func Punct() []byte
- func String[T Char](min, max int, bs []T) string
- func UpperAlpha() []byte
- type Char
- type Rands
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes 从 bs 中随机抓取 [min,max) 个字符并返回
NOTE: bs 的类型可以是 rune,但是返回类型始终是 []byte,所以用 len 判断返回值可能其值会很大。
Types ¶
Click to show internal directories.
Click to hide internal directories.