Documentation ¶
Index ¶
- Constants
- Variables
- func Generate(opts ...GenerationOption) (string, error)
- func MustGenerate(opts ...GenerationOption) string
- type DefaultGenerator
- type GenerationOption
- func WithDigits(digits uint) GenerationOption
- func WithLength(length uint) GenerationOption
- func WithLetters(letters uint) GenerationOption
- func WithLowercase(lowercase uint) GenerationOption
- func WithSpecials(specials uint) GenerationOption
- func WithSpecialsAlphabet(specialsAlphabet string) GenerationOption
- func WithUppercase(uppercase uint) GenerationOption
- type Generator
- type Int32n
Constants ¶
View Source
const ( DefaultLength = 20 DefaultSpecialsAlphabet = `!?~@#$%^&*()-+={}[]\/{}|<>` )
Variables ¶
View Source
var (
Default = NewDefaultGenerator(nil)
)
View Source
var ErrLengthOverflow = errors.New("length overflow")
Functions ¶
func Generate ¶
func Generate(opts ...GenerationOption) (string, error)
func MustGenerate ¶
func MustGenerate(opts ...GenerationOption) string
Types ¶
type DefaultGenerator ¶
type DefaultGenerator struct {
PRNG Int32n
}
func NewDefaultGenerator ¶
func NewDefaultGenerator(prng Int32n) DefaultGenerator
func (DefaultGenerator) Generate ¶
func (d DefaultGenerator) Generate(opts ...GenerationOption) (string, error)
type GenerationOption ¶
type GenerationOption interface {
ApplyToOptions(options *options)
}
func WithDigits ¶
func WithDigits(digits uint) GenerationOption
func WithLength ¶
func WithLength(length uint) GenerationOption
func WithLetters ¶
func WithLetters(letters uint) GenerationOption
func WithLowercase ¶
func WithLowercase(lowercase uint) GenerationOption
func WithSpecials ¶
func WithSpecials(specials uint) GenerationOption
func WithSpecialsAlphabet ¶
func WithSpecialsAlphabet(specialsAlphabet string) GenerationOption
func WithUppercase ¶
func WithUppercase(uppercase uint) GenerationOption
type Generator ¶
type Generator interface {
Generate(opts ...GenerationOption) (string, error)
}
Click to show internal directories.
Click to hide internal directories.