pathgen

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PathGenerator

type PathGenerator struct {
	Rnd *rand.Rand
	// contains filtered or unexported fields
}

Generates paths, separated with a slash or custom separator. The paths have a random number of filenames in them, and the filenames consist of random characters of random length. The generated sequences are reproducible, controlled by the RandSeed option.

func New

Creates a path generator with the provided options, falling back to the default value for each non-specified option field.

func (*PathGenerator) Between

func (pg *PathGenerator) Between(min, max int) int

takes a random number positioned between [min, max)

func (*PathGenerator) Name

func (pg *PathGenerator) Name() string

generates a random name using the available characters and of length within the defined boundaries

func (*PathGenerator) Names

func (pg *PathGenerator) Names() []string

generates random names of count between the defined boundaries

func (*PathGenerator) Next

func (pg *PathGenerator) Next() string

Generates a random path.

The path will be always absolute.

The path may contain a closing slash, with a probability based on the `ClosingSlashInEveryN`. If `ClosingSlashInEveryN < 0`, the path won't contain a closing slash. If `ClosingSlashInEveryN == 0`, the path will always contain a closing slash. If `ClosingSlashInEveryN == n`, where `n > 0`, then the generated path will contain a closing slash with a chance of `1 / n`.

The path will contain a random number of names (the thing between the slashes), equally distributed between `MinNamesInPath` and `MaxNamesInPath`.

The names in the path will have a random length, equally distributed between `MinFilenameLength` and `MaxFilenameLength`.

The sequence followed by `Next` is reproducible, to get a different sequence, a new PathGenerator instance is required, with a different `RandSeed` value.

func (*PathGenerator) Str

func (pg *PathGenerator) Str(min, max int) string

func (*PathGenerator) Strs

func (pg *PathGenerator) Strs(min, max, minLength, maxLength int) []string

type PathGeneratorOptions

type PathGeneratorOptions struct {
	FilenameChars        string
	MinFilenameLength    int
	MaxFilenameLength    int
	MinNamesInPath       int
	MaxNamesInPath       int
	ClosingSlashInEveryN int
	RandSeed             int64
	Separator            string
}

Jump to

Keyboard shortcuts

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