func NewGenerator(alphabet []rune, length int) (Generator, error) {
	if len(alphabet) == 0 {
		return Generator{}, errors.New("Alphabet has length 0")
	}

	set := make(map[rune]int)
	for i, v := range alphabet {
		if pos, exists := set[v]; exists {
			return Generator{}, errors.Errorf("Duplicate character %q in alphabet at offset %d; already found at offset %d", v, i, pos)
		}
		set[v] = i
	}

	return Generator{alphabet, length, rand.Reader}, nil
}
// NewGenerator creates a Generator from the given alphabet and length.
// Unless SetRandomSource is called, the default source of random bytes, crypto/rand.Reader will be used.
// An error is returned if len(alphabet) == 0,
// or if there are duplicate characters in the alphabet.
NewGenerator creates a Generator from the given alphabet and length.
Unless SetRandomSource is called, the default source of random bytes, crypto/rand.Reader will be used.
An error is returned if len(alphabet) == 0,
or if there are duplicate characters in the alphabet.
// NewGenerator creates a Generator from the given alphabet and length . // Unless SetRandomSource is called the default source of random bytes crypto / rand . Reader will be used . // An error is returned if len ( alphabet ) == 0 // or if there are duplicate characters in the alphabet .
func NewGenerator(alphabet []rune, length int) (Generator, error) {
	if len(alphabet) == 0 {
		return Generator{}, errors.New("Alphabet has length 0")
	}
	set := make(map[rune]int)
	for i, v := range alphabet {
		if pos, exists := set[v]; exists {
			return Generator{}, errors.Errorf("Duplicate character %q in alphabet at offset %d; already found at offset %d", v, i, pos)
		}
		set[v] = i
	}
	return Generator{alphabet, length, rand.Reader}, nil
}
func NewGenerator ( alphabet [ ] rune , length int ) ( Generator , error ) { if len ( alphabet ) == 0 { return Generator { } , errors . New ( " " ) } set := make ( map [ rune ] int ) for i , v := range alphabet { if pos , exists := set [ v ] ; exists { return Generator { } , errors . Errorf ( " " , v , i , pos ) } set [ v ] = i } return Generator { alphabet , length , rand . Reader } , nil }
NewGenerator creates a Generator from the given alphabet and length.
NewGenerator creates a Generator from the given alphabet and length .