summaryrefslogtreecommitdiff
path: root/random
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2025-03-09 20:14:46 -0400
committerGitHub <noreply@github.com>2025-03-10 00:14:46 +0000
commitbfa6b9dcef7592e6dd8225aaa0d0ab5aef5b3f84 (patch)
tree7e844defee92dc3af320df20baa6f9b421d4a4c9 /random
parent7942441e61471f578a57910b3aa93636f5a0310d (diff)
chore(refactoring): Refactor/modernizations (#2345)
chore(refactoring): Refactor with modernization refactorings * range over int * replace interface{} with any * replace common map operations with maps.Copy/maps.Clone * simplifying loops with slices.Contains/ContainsFunc * modernize benchmarks with b.Loop * modernize tests with t.Context * use fmt.Appendf * range over strings.SplitSeq * use new stdlib crypto/pbkdf2 package --------- Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'random')
-rw-r--r--random/random.go2
-rw-r--r--random/random_test.go6
2 files changed, 4 insertions, 4 deletions
diff --git a/random/random.go b/random/random.go
index ad0bb48a..4feb2884 100644
--- a/random/random.go
+++ b/random/random.go
@@ -74,7 +74,7 @@ func matchChars(match string) ([]rune, error) {
}
// Item -
-func Item(items []interface{}) (interface{}, error) {
+func Item(items []any) (any, error) {
if len(items) == 0 {
return nil, fmt.Errorf("expected a non-empty array or slice")
}
diff --git a/random/random_test.go b/random/random_test.go
index 1e76298e..0722465e 100644
--- a/random/random_test.go
+++ b/random/random_test.go
@@ -82,13 +82,13 @@ func TestItem(t *testing.T) {
_, err := Item(nil)
require.Error(t, err)
- i, err := Item([]interface{}{"foo"})
+ i, err := Item([]any{"foo"})
require.NoError(t, err)
assert.Equal(t, "foo", i)
- in := []interface{}{"foo", "bar"}
+ in := []any{"foo", "bar"}
got := ""
- for j := 0; j < 10; j++ {
+ for range 10 {
i, err = Item(in)
require.NoError(t, err)
got += i.(string)