From bfa6b9dcef7592e6dd8225aaa0d0ab5aef5b3f84 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 9 Mar 2025 20:14:46 -0400 Subject: 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 --- random/random.go | 2 +- random/random_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'random') 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) -- cgit v1.2.3