-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.go
53 lines (44 loc) · 873 Bytes
/
option.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
46
47
48
49
50
51
52
53
package gopass
const (
numbers = "0123456789"
lowerCase = "abcdefghijklmnopqrstuvwxyz"
upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
letters = lowerCase + upperCase
symbols = "~!@#$%^&*()_+{}|:<>?,./"
)
type Option func(*Generator)
func Numbers() Option {
return func(g *Generator) {
g.chars.WriteString(numbers)
}
}
func UpperCase() Option {
return func(g *Generator) {
g.chars.WriteString(upperCase)
}
}
func LowerCase() Option {
return func(g *Generator) {
g.chars.WriteString(lowerCase)
}
}
func Letters() Option {
return func(g *Generator) {
g.chars.WriteString(letters)
}
}
func Symbols() Option {
return func(g *Generator) {
g.chars.WriteString(symbols)
}
}
func String(s string) Option {
return func(g *Generator) {
g.chars.WriteString(s)
}
}
func Bytes(b []byte) Option {
return func(g *Generator) {
g.chars.Write(b)
}
}