Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description to create random files functions #59

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions io/fileutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var src = rand.NewSource(time.Now().UnixNano())
// #nosec G404 - No cryptographic level encryption is needed in random file
var rnd = rand.New(src)

// Create a temp file with the requested prefix at the provided dir. File length and contents are random, up to the requested max length.
func CreateRandomLenFile(maxLen int, filesDir string, prefix string) string {
file, _ := os.CreateTemp(filesDir, prefix)
fname := file.Name()
Expand All @@ -41,6 +42,7 @@ func CreateRandomLenFile(maxLen int, filesDir string, prefix string) string {
return fname
}

// Create a file at the provided path with a request number of random bytes.
func CreateRandFile(path string, len int) (file *RandFile, err error) {
f, err := os.Create(path)
if err != nil {
Expand Down
Loading