-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
45 lines (45 loc) · 1.14 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Package randomstring provides:
//
// - function `Generate` to generate random string based on set of characters
//
// - type `Generator` to generate random string based on set of rules
//
// Example
//
// This code:
//
// gen := randomstring.New(randomstring.NewLength(20), randomstring.NewInlcudeCharset(randomstring.LowerLetters), randomstring.NewNoDuplicateCharacters())
// fmt.Println(gen.Generate())
//
// will generate random string that:
//
// - has length 20
//
// - contains lowercase latin letters
//
// - all letters in random string are unique
//
// Custom rules
//
// Generator accept four types of rules:
//
// - Length rule that defines a random string length
//
// - Charset rule that build a character set
//
// - Output rule that checks built string
//
// - Generator rule that generates a random string
//
// All types can be customized, ex:
//
// func NewCustomCharset() CharsetRuleFunc {
// return CharsetRuleFunc(func(charset string) string {
// return "abc"
// })
// }
//
// Usage:
//
// gen := randomstring.New(randomstring.NewLength(20), NewCustomCharset(), randomstring.NewNoDuplicateCharacters())
package randomstring