Documentation
¶
Overview ¶
Package files provides functionality for creating filesystem hierarchies of random files an directories. This is useful for testing that needs to operate on directory trees. Random results are reproducible by reusing the same seed. Random values are not cryptographically secure.
Index ¶
Constants ¶
const (
MinimumNameSize = 4
)
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create creates random files and directories according to the provided configuration. The random files and directories are created in the specified root paths.
func RandomName ¶ added in v0.2.3
RandomName generates a random file or directory name.
If no sizes are specified, then the default minimum and maximum name sizes are used. If one size is specified, then the name will have that size. If two sizes are specified, then the name will have a random size between the smaller and larger of the two numbers.
Types ¶
type Config ¶
type Config struct {
// Depth is the depth of the directory tree including the root directory.
Depth int
// Dirs is the number of subdirectories at each depth.
Dirs int
// Files is the number of files at each depth.
Files int
// FileSize sets the number of random bytes in each file.
FileSize int64
// NameMaxSize is the maximum length of a random file or directory name.
NameMaxSize int
// NameMinSize is the minimum length of a random file or directory name. It
// must be at least MinimumNameSize.
NameMinSize int
// Where to write display output, such as os.Stdout. Default is nil.
Out io.Writer
// RandomDirss specifies whether or not to randomize the number of
// subdirectories from 1 to the value configured by Dirs.
RandomDirs bool
// RandomFiles specifies whether or not to randomize the number of files
// from 1 to the value configured by Files.
RandomFiles bool
// RandomSize specifies whether or not to randomize the file size from 1 to
// the value configured by FileSize.
RandomSize bool
// Seed sets the seed for the random number generator when set to a
// non-empty value.
Seed string
}
Config contains settings for creating random files and directories.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default settings for creating random files and directories.