feat: add MustGenerate overload
This commit is contained in:
parent
997460bbdc
commit
81e23c0436
1 changed files with 8 additions and 0 deletions
8
pwgen.go
8
pwgen.go
|
@ -18,6 +18,14 @@ func Generate(opts ...GenerationOption) (string, error) {
|
|||
return Default.Generate(opts...)
|
||||
}
|
||||
|
||||
func MustGenerate(opts ...GenerationOption) string {
|
||||
if pw, err := Generate(opts...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return pw
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefaultGenerator(prng Int32n) DefaultGenerator {
|
||||
if prng == nil {
|
||||
prng = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
|
Loading…
Reference in a new issue