summaryrefslogtreecommitdiff
path: root/random
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2024-11-10 15:38:25 -0500
committerGitHub <noreply@github.com>2024-11-10 20:38:25 +0000
commita13844c9c0a3d03e0fba4627a51445ca9ae8100b (patch)
tree335758c94d0f8087e549af92c502ba767335f102 /random
parentd4647871a06410549748b242547991736be96c8c (diff)
fix(lint): Address new lint warnings from golangci-lint 1.62 (#2256)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'random')
-rw-r--r--random/random.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/random/random.go b/random/random.go
index e3fd2390..ad0bb48a 100644
--- a/random/random.go
+++ b/random/random.go
@@ -4,7 +4,7 @@ package random
import (
"fmt"
"math"
- "math/rand"
+ "math/rand/v2"
"regexp"
"unicode"
)
@@ -43,7 +43,7 @@ func rndString(count int, chars []rune) (string, error) {
s := make([]rune, count)
for i := range s {
//nolint:gosec
- s[i] = chars[rand.Intn(len(chars))]
+ s[i] = chars[rand.IntN(len(chars))]
}
return string(s), nil
}
@@ -83,11 +83,13 @@ func Item(items []interface{}) (interface{}, error) {
}
//nolint:gosec
- n := rand.Intn(len(items))
+ n := rand.IntN(len(items))
return items[n], nil
}
// Number -
+//
+//nolint:revive
func Number(min, max int64) (int64, error) {
if min > max {
return 0, fmt.Errorf("min must not be greater than max (was %d, %d)", min, max)
@@ -100,10 +102,12 @@ func Number(min, max int64) (int64, error) {
}
//nolint:gosec
- return rand.Int63n(max-min+1) + min, nil
+ return rand.Int64N(max-min+1) + min, nil
}
// Float - For now this is really just a wrapper around `rand.Float64`
+//
+//nolint:revive
func Float(min, max float64) (float64, error) {
//nolint:gosec
return min + rand.Float64()*(max-min), nil