func (g Generator) GenerateManyWithLength(amount, length uint) ([]string, error) {
	var generated []string
	for i := uint(0); i < amount; i++ {
		str, err := g.GenerateWithLength(length)
		if err != nil {
			return nil, err
		}
		generated = append(generated, *str)
	}
	return generated, nil
}
GenerateManyWithLength generates multiple passwords with set length
package generator
import (
	"crypto/rand"
	"errors"
	"math/big"
	"strings"
)
const (
	LengthWeak uint = 6
	LengthOK uint = 12
	LengthStrong uint = 24
	LengthVeryStrong uint = 36
	DefaultLetterSet = "abcdefghijklmnopqrstuvwxyz"
	DefaultLetterAmbiguousSet = "ijlo"
	DefaultNumberSet = "0123456789"
	DefaultNumberAmbiguousSet = "01"
	DefaultSymbolSet = "!$%^&*()_+{}:@[];'#<>?,./|\\-=?"
	DefaultSymbolAmbiguousSet = "<>[](){}:;'/|\\,"
)
var (
	DefaultConfig = Config{
		Length:                     LengthStrong,
		IncludeSymbols:             true,
		IncludeNumbers:             true,
		IncludeLowercaseLetters:    true,
		IncludeUppercaseLetters:    true,
		ExcludeSimilarCharacters:   true,
		ExcludeAmbiguousCharacters: true,
	}
	ErrConfigIsEmpty = errors.New("config is empty")
)
type Generator struct {
	*Config
}
type Config struct {
	Length uint
	CharacterSet string
	IncludeSymbols bool
	IncludeNumbers bool
	IncludeLowercaseLetters bool
	IncludeUppercaseLetters bool
	ExcludeSimilarCharacters bool
	ExcludeAmbiguousCharacters bool
}
func New(config *Config) (*Generator, error) {
	if config == nil {
		config = &DefaultConfig
	}
	if !config.IncludeSymbols &&
		!config.IncludeUppercaseLetters &&
		!config.IncludeLowercaseLetters &&
		!config.IncludeNumbers &&
		config.CharacterSet == "" {
		return nil, ErrConfigIsEmpty
	}
	if config.Length == 0 {
		config.Length = LengthStrong
	}
	if config.CharacterSet == "" {
		config.CharacterSet = buildCharacterSet(config)
	}
	return &Generator{Config: config}, nil
}
func buildCharacterSet(config *Config) string {
	var characterSet string
	if config.IncludeLowercaseLetters {
		characterSet += DefaultLetterSet
		if config.ExcludeSimilarCharacters {
			characterSet = removeCharacters(characterSet, DefaultLetterAmbiguousSet)
		}
	}
	if config.IncludeUppercaseLetters {
		characterSet += strings.ToUpper(DefaultLetterSet)
		if config.ExcludeSimilarCharacters {
			characterSet = removeCharacters(characterSet, strings.ToUpper(DefaultLetterAmbiguousSet))
		}
	}
	if config.IncludeNumbers {
		characterSet += DefaultNumberSet
		if config.ExcludeSimilarCharacters {
			characterSet = removeCharacters(characterSet, DefaultNumberAmbiguousSet)
		}
	}
	if config.IncludeSymbols {
		characterSet += DefaultSymbolSet
		if config.ExcludeAmbiguousCharacters {
			characterSet = removeCharacters(characterSet, DefaultSymbolAmbiguousSet)
		}
	}
	return characterSet
}
func removeCharacters(str, characters string) string {
	return strings.Map(func(r rune) rune {
		if !strings.ContainsRune(characters, r) {
			return r
		}
		return -1
	}, str)
}
func NewWithDefault() (*Generator, error) {
	return New(&DefaultConfig)
}
func (g Generator) Generate() (*string, error) {
	var generated string
	characterSet := strings.Split(g.Config.CharacterSet, "")
	max := big.NewInt(int64(len(characterSet)))
	for i := uint(0); i < g.Config.Length; i++ {
		val, err := rand.Int(rand.Reader, max)
		if err != nil {
			return nil, err
		}
		generated += characterSet[val.Int64()]
	}
	return &generated, nil
}
func (g Generator) GenerateMany(amount uint) ([]string, error) {
	var generated []string
	for i := uint(0); i < amount; i++ {
		str, err := g.Generate()
		if err != nil {
			return nil, err
		}
		generated = append(generated, *str)
	}
	return generated, nil
}
func (g Generator) GenerateWithLength(length uint) (*string, error) {
	var generated string
	characterSet := strings.Split(g.Config.CharacterSet, "")
	max := big.NewInt(int64(len(characterSet)))
	for i := uint(0); i < length; i++ {
		val, err := rand.Int(rand.Reader, max)
		if err != nil {
			return nil, err
		}
		generated += characterSet[val.Int64()]
	}
	return &generated, nil
}