randfiletree

package module
v0.0.0-...-41d6c1d Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

randfiletree

A file tree generator providing various (random and non-random) customization options

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FileNameAlphabetBasic represents a "safe" alphabet restricted to lowercase/uppercase characters and numbers
	FileNameAlphabetBasic = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890")

	// FileNameAlphabetLinux represents an alphabet compatible with common linux systems
	FileNameAlphabetLinux = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()-_+= ;.,")
)

Functions

This section is empty.

Types

type BooleanGenerator

type BooleanGenerator func(r *rand.Rand) bool

BooleanGenerator generates a true / false value

func BooleanGeneratorProbabilityFlat

func BooleanGeneratorProbabilityFlat(prob float64) BooleanGenerator

BooleanGeneratorProbabilityFlat returns a random boolean with a given probablity of being true

type DataGenerator

type DataGenerator func(r *rand.Rand) ([]byte, error)

DataGenerator denotes a generic data generator

func DataGeneratorFixed

func DataGeneratorFixed(data []byte) DataGenerator

DataGeneratorFixed returns a fixed set of bytes

func DataGeneratorFixedString

func DataGeneratorFixedString(str string) DataGenerator

DataGeneratorFixedString returns a fixed set of bytes based on a string

func DataGeneratorRandom

func DataGeneratorRandom(lengthGen NumberGenerator) DataGenerator

DataGeneratorRandom returns a random set of bytes of randomized length

func DataGeneratorRandomFixedLen

func DataGeneratorRandomFixedLen(length int) DataGenerator

DataGeneratorRandomFixedLen returns a random set of bytes of requested length

type FileModeGenerator

type FileModeGenerator func(r *rand.Rand) uint32

FileModeGenerator denotes a generic generator function for file modes (i.e. uint32)

func FileModeGeneratorConstant

func FileModeGeneratorConstant(mode uint32) FileModeGenerator

FileModeGeneratorConstant returns a fixed file mode

type FileNameGenerator

type FileNameGenerator = StringGenerator

FileNameGenerator is basically just a string generator

type FileNameLenGenerator

type FileNameLenGenerator = NumberGenerator

FileNameLenGenerator is basically just an integer number generator

type Generator

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

Generator denotes a filetree generator

func New

func New(basePath string) *Generator

New instantiates a new generator

func (*Generator) RemoveAll

func (g *Generator) RemoveAll() error

RemoveAll removes (and recreates) the directory

func (*Generator) Run

func (g *Generator) Run() error

Run generates a new tree (or adds to an existing one) according to the defined rules

func (*Generator) Seed

func (g *Generator) Seed(seed int64) *Generator

Seed sets a new seed (and a new random source, for that matter)

func (*Generator) Walk

func (g *Generator) Walk(fn filepath.WalkFunc) error

Walk performs a recursive walk through the provided directory (wrapping filepath.Walk())

type NumberGenerator

type NumberGenerator func(r *rand.Rand) int

NumberGenerator denotes a generic generator function for integers (e.g. for length of strings or data)

func NumberGeneratorConstant

func NumberGeneratorConstant(val int) NumberGenerator

NumberGeneratorConstant generates a constant number

func NumberGeneratorRandomFlat

func NumberGeneratorRandomFlat(min, max int) NumberGenerator

NumberGeneratorRandomFlat generates a random number out of a range (equal probabilities)

type StringGenerator

type StringGenerator func(r *rand.Rand, length int) string

StringGenerator denotes a generic generator function for strings (e.g. for filenames)

func StringGeneratorAlphabet

func StringGeneratorAlphabet(alphabet []rune) StringGenerator

StringGeneratorAlphabet generates a string of requested length based on a provided alphabet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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