Documentation
¶
Overview ¶
Package random provides functions for generating random data
Index ¶
- func CreateFile(path string, size int64) error
- func CreateFiles(dir string, minFiles int, maxFiles int, minSize uint64, maxSize uint64, ...) (uint64, error)
- func CreateTempFile(dir, pattern string, size int64) (string, error)
- func Int(min int, max int) int
- func Path(base string, minDirs int, maxDirs int, minNameLen int, maxNameLen int) string
- func Paths(base string, count int, min int, max int, minNameLen int, maxNameLen int) []string
- func SecureBytes(b []byte) error
- func SecureUint32() (uint32, error)
- func SecureUint64() (uint64, error)
- func String(n int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateFile ¶
Create a file and fill it with random bytes. NOTE: This will override any existing file. path The path of the file to be created. size The number of random bytes to write to the file.
func CreateFiles ¶
func CreateFiles(dir string, minFiles int, maxFiles int, minSize uint64, maxSize uint64, maxTotalSize uint64) (uint64, error)
Generate random files inside the specified directory Files will be created using data copied from the crypto random generator. dir: is the parent directory minFile: minimum number of files to create maxFile: maximum number of files to create minSize: the minimum size in bytes of a file. maxSize: the maximum size in bytes of a file. maxTotalSize: the maximum number of bytes to be used for all files being created. Return the total number of bytes written.
func CreateTempFile ¶
Create a temporary file and fill it with random bytes. NOTE: This will override any existing file. See os.CreateTemp for details on dir and pattern. size The number of random bytes to write to the file. Returns the path to the file that was created.
func Path ¶
Generate a path consisting of random depth (subdirectories) between min and max minDirs, maxDirs: random range between the minimum and maximum amount of subdirectories to create minNameLen, maxNameLen: random range of length of characters used to generate each random subdirectory's name. The function will always return the base + range(min, max) paths.
func Paths ¶
Generate a slice of random paths count: is the number of random paths to create and return
func SecureBytes ¶
Read len(b) bytes into b from the secure random number generator.
func SecureUint32 ¶
Read 4 bytes from the secure random number generator and convert it to an uint32.
func SecureUint64 ¶
Read 8 bytes from the secure random number generator and convert it to an uint64.
Types ¶
This section is empty.