From abc0677b2cdbfb9c859c5dd2e281af07e0726375 Mon Sep 17 00:00:00 2001 From: Seednode Date: Thu, 8 Feb 2024 16:37:49 -0600 Subject: [PATCH] Replace crypto/rand with math/rand/v2 to test --- cmd/files.go | 24 +++++------------------- cmd/root.go | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index 19d8b94..180d2dc 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -8,15 +8,11 @@ import ( "errors" "fmt" "io/fs" - "math/big" - "regexp" - "runtime" - "slices" - - "crypto/rand" + "math/rand/v2" "os" "path/filepath" - "strconv" + "runtime" + "slices" "strings" "sync" "time" @@ -462,19 +458,9 @@ func pickFile(list []string) (string, error) { return "", nil case fileCount < 1: return "", ErrNoMediaFound - } + } - r, err := rand.Int(rand.Reader, big.NewInt(int64(fileCount))) - if err != nil { - return "", err - } - - val, err := strconv.Atoi(strconv.FormatInt(r.Int64(), 10)) - if err != nil { - return "", err - } - - return list[val], nil + return list[rand.IntN(fileCount)], nil } func preparePath(prefix, path string) string { diff --git a/cmd/root.go b/cmd/root.go index 4d8e4a6..999d5dd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "8.6.1" + ReleaseVersion string = "8.7.0" ) var (