generator

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyAlphabet is the error returned by NewString when providing an
	// empty alphabet string.
	ErrEmptyAlphabet = errors.New("alphabet should not be empty")

	// ErrNotASCIIAlphabet is the error returned by NewString when the alphabet
	// contains some non-ASCII runes.
	ErrNotASCIIAlphabet = errors.New("alphabet should only contain ASCII runes")
)

Functions

This section is empty.

Types

type Bitstring

type Bitstring uint

Bitstring generates random bit strings of a specified length.

func (Bitstring) Generate

func (i Bitstring) Generate(rng *rand.Rand) interface{}

Generate generates a random bit string in which the distribution of ones and zeroes depends on rng.

type String

type String struct {
	// contains filtered or unexported fields
}

String is a generator of ASCII string candidates of the specified length and in which runes are randomly chosen from an alphabet

func NewString

func NewString(alphabet string, length int) (*String, error)

NewString returns a String that generates strings of the specified length from the provided alphabet.

NewString will return ErrEmptyAlphabet if the alphabet is empty and ErrNotASCIIAlphabet if the alphabet contains some non-ASCII runes.

func (*String) Generate

func (gen *String) Generate(rng *rand.Rand) interface{}

Generate generates a random string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL