diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
commit | b80853de90b10171155b8f3fde47d64ec7bfa0dd (patch) | |
tree | 435d3dbf7a495a0c6ce64c9769e037179aa0d27b /tpl/collections | |
parent | 423594e03a906ef4150f433666ff588b022c3c92 (diff) |
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/collections')
-rw-r--r-- | tpl/collections/append.go | 2 | ||||
-rw-r--r-- | tpl/collections/append_test.go | 18 | ||||
-rw-r--r-- | tpl/collections/apply.go | 12 | ||||
-rw-r--r-- | tpl/collections/apply_test.go | 8 | ||||
-rw-r--r-- | tpl/collections/collections.go | 66 | ||||
-rw-r--r-- | tpl/collections/collections_test.go | 300 | ||||
-rw-r--r-- | tpl/collections/complement.go | 2 | ||||
-rw-r--r-- | tpl/collections/complement_test.go | 34 | ||||
-rw-r--r-- | tpl/collections/index.go | 4 | ||||
-rw-r--r-- | tpl/collections/index_test.go | 34 | ||||
-rw-r--r-- | tpl/collections/init.go | 2 | ||||
-rw-r--r-- | tpl/collections/merge.go | 4 | ||||
-rw-r--r-- | tpl/collections/merge_test.go | 90 | ||||
-rw-r--r-- | tpl/collections/reflect_helpers.go | 8 | ||||
-rw-r--r-- | tpl/collections/sort.go | 4 | ||||
-rw-r--r-- | tpl/collections/sort_test.go | 24 | ||||
-rw-r--r-- | tpl/collections/symdiff.go | 4 | ||||
-rw-r--r-- | tpl/collections/symdiff_test.go | 8 | ||||
-rw-r--r-- | tpl/collections/where.go | 10 | ||||
-rw-r--r-- | tpl/collections/where_test.go | 74 |
20 files changed, 354 insertions, 354 deletions
diff --git a/tpl/collections/append.go b/tpl/collections/append.go index 50fafe3d9..752ad2fa0 100644 --- a/tpl/collections/append.go +++ b/tpl/collections/append.go @@ -25,7 +25,7 @@ import ( // Note that with 2 arguments where both are slices of the same type, // the first slice will be appended to the second: // {{ $pages = $pages | append .Site.RegularPages }} -func (ns *Namespace) Append(args ...interface{}) (interface{}, error) { +func (ns *Namespace) Append(args ...any) (any, error) { if len(args) < 2 { return nil, errors.New("need at least 2 arguments to append") } diff --git a/tpl/collections/append_test.go b/tpl/collections/append_test.go index 9dcc7d2b9..02e46039f 100644 --- a/tpl/collections/append_test.go +++ b/tpl/collections/append_test.go @@ -29,20 +29,20 @@ func TestAppend(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - start interface{} - addend []interface{} - expected interface{} + start any + addend []any + expected any }{ - {[]string{"a", "b"}, []interface{}{"c"}, []string{"a", "b", "c"}}, - {[]string{"a", "b"}, []interface{}{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}}, - {[]string{"a", "b"}, []interface{}{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}}, + {[]string{"a", "b"}, []any{"c"}, []string{"a", "b", "c"}}, + {[]string{"a", "b"}, []any{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}}, + {[]string{"a", "b"}, []any{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}}, // Errors - {"", []interface{}{[]string{"a", "b"}}, false}, - {[]string{"a", "b"}, []interface{}{}, false}, + {"", []any{[]string{"a", "b"}}, false}, + {[]string{"a", "b"}, []any{}, false}, // No string concatenation. { "ab", - []interface{}{"c"}, + []any{"c"}, false, }, } { diff --git a/tpl/collections/apply.go b/tpl/collections/apply.go index 55bab5d1a..3b8de5f0e 100644 --- a/tpl/collections/apply.go +++ b/tpl/collections/apply.go @@ -25,9 +25,9 @@ import ( ) // Apply takes a map, array, or slice and returns a new slice with the function fname applied over it. -func (ns *Namespace) Apply(ctx context.Context, seq interface{}, fname string, args ...interface{}) (interface{}, error) { +func (ns *Namespace) Apply(ctx context.Context, seq any, fname string, args ...any) (any, error) { if seq == nil { - return make([]interface{}, 0), nil + return make([]any, 0), nil } if fname == "apply" { @@ -47,7 +47,7 @@ func (ns *Namespace) Apply(ctx context.Context, seq interface{}, fname string, a switch seqv.Kind() { case reflect.Array, reflect.Slice: - r := make([]interface{}, seqv.Len()) + r := make([]any, seqv.Len()) for i := 0; i < seqv.Len(); i++ { vv := seqv.Index(i) @@ -65,10 +65,10 @@ func (ns *Namespace) Apply(ctx context.Context, seq interface{}, fname string, a } } -func applyFnToThis(ctx context.Context, fn, this reflect.Value, args ...interface{}) (reflect.Value, error) { +func applyFnToThis(ctx context.Context, fn, this reflect.Value, args ...any) (reflect.Value, error) { num := fn.Type().NumIn() if num > 0 && fn.Type().In(0).Implements(hreflect.ContextInterface) { - args = append([]interface{}{ctx}, args...) + args = append([]any{ctx}, args...) } n := make([]reflect.Value, len(args)) @@ -120,7 +120,7 @@ func (ns *Namespace) lookupFunc(fname string) (reflect.Value, bool) { return reflect.Value{}, false } - fn, ok := nv.Interface().(func(...interface{}) (interface{}, error)) + fn, ok := nv.Interface().(func(...any) (any, error)) if !ok { return reflect.Value{}, false } diff --git a/tpl/collections/apply_test.go b/tpl/collections/apply_test.go index 9ad0f405d..315f2bc85 100644 --- a/tpl/collections/apply_test.go +++ b/tpl/collections/apply_test.go @@ -48,11 +48,11 @@ func (templateFinder) LookupLayout(d output.LayoutDescriptor, f output.Format) ( return nil, false, nil } -func (templateFinder) Execute(t tpl.Template, wr io.Writer, data interface{}) error { +func (templateFinder) Execute(t tpl.Template, wr io.Writer, data any) error { return nil } -func (templateFinder) ExecuteWithContext(ctx context.Context, t tpl.Template, wr io.Writer, data interface{}) error { +func (templateFinder) ExecuteWithContext(ctx context.Context, t tpl.Template, wr io.Writer, data any) error { return nil } @@ -71,13 +71,13 @@ func TestApply(t *testing.T) { d.SetTmpl(new(templateFinder)) ns := New(d) - strings := []interface{}{"a\n", "b\n"} + strings := []any{"a\n", "b\n"} ctx := context.Background() result, err := ns.Apply(ctx, strings, "print", "a", "b", "c") c.Assert(err, qt.IsNil) - c.Assert(result, qt.DeepEquals, []interface{}{"abc", "abc"}) + c.Assert(result, qt.DeepEquals, []any{"abc", "abc"}) _, err = ns.Apply(ctx, strings, "apply", ".") c.Assert(err, qt.Not(qt.IsNil)) diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go index 0a9774aa4..24f43e62c 100644 --- a/tpl/collections/collections.go +++ b/tpl/collections/collections.go @@ -50,7 +50,7 @@ type Namespace struct { } // After returns all the items after the first N in a rangeable list. -func (ns *Namespace) After(index interface{}, seq interface{}) (interface{}, error) { +func (ns *Namespace) After(index any, seq any) (any, error) { if index == nil || seq == nil { return nil, errors.New("both limit and seq must be provided") } @@ -86,7 +86,7 @@ func (ns *Namespace) After(index interface{}, seq interface{}) (interface{}, err // Delimit takes a given sequence and returns a delimited HTML string. // If last is passed to the function, it will be used as the final delimiter. -func (ns *Namespace) Delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, error) { +func (ns *Namespace) Delimit(seq, delimiter any, last ...any) (template.HTML, error) { d, err := cast.ToStringE(delimiter) if err != nil { return "", err @@ -146,12 +146,12 @@ func (ns *Namespace) Delimit(seq, delimiter interface{}, last ...interface{}) (t // walking the parameters and treating them as key-value pairs. The number // of parameters must be even. // The keys can be string slices, which will create the needed nested structure. -func (ns *Namespace) Dictionary(values ...interface{}) (map[string]interface{}, error) { +func (ns *Namespace) Dictionary(values ...any) (map[string]any, error) { if len(values)%2 != 0 { return nil, errors.New("invalid dictionary call") } - root := make(map[string]interface{}) + root := make(map[string]any) for i := 0; i < len(values); i += 2 { dict := root @@ -162,12 +162,12 @@ func (ns *Namespace) Dictionary(values ...interface{}) (map[string]interface{}, case []string: for i := 0; i < len(v)-1; i++ { key = v[i] - var m map[string]interface{} + var m map[string]any v, found := dict[key] if found { - m = v.(map[string]interface{}) + m = v.(map[string]any) } else { - m = make(map[string]interface{}) + m = make(map[string]any) dict[key] = m } dict = m @@ -184,7 +184,7 @@ func (ns *Namespace) Dictionary(values ...interface{}) (map[string]interface{}, // EchoParam returns a given value if it is set; otherwise, it returns an // empty string. -func (ns *Namespace) EchoParam(a, key interface{}) interface{} { +func (ns *Namespace) EchoParam(a, key any) any { av, isNil := indirect(reflect.ValueOf(a)) if isNil { return "" @@ -227,7 +227,7 @@ func (ns *Namespace) EchoParam(a, key interface{}) interface{} { } // First returns the first N items in a rangeable list. -func (ns *Namespace) First(limit interface{}, seq interface{}) (interface{}, error) { +func (ns *Namespace) First(limit any, seq any) (any, error) { if limit == nil || seq == nil { return nil, errors.New("both limit and seq must be provided") } @@ -262,7 +262,7 @@ func (ns *Namespace) First(limit interface{}, seq interface{}) (interface{}, err } // In returns whether v is in the set l. l may be an array or slice. -func (ns *Namespace) In(l interface{}, v interface{}) (bool, error) { +func (ns *Namespace) In(l any, v any) (bool, error) { if l == nil || v == nil { return false, nil } @@ -301,9 +301,9 @@ func (ns *Namespace) In(l interface{}, v interface{}) (bool, error) { // Intersect returns the common elements in the given sets, l1 and l2. l1 and // l2 must be of the same type and may be either arrays or slices. -func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error) { +func (ns *Namespace) Intersect(l1, l2 any) (any, error) { if l1 == nil || l2 == nil { - return make([]interface{}, 0), nil + return make([]any, 0), nil } var ins *intersector @@ -313,19 +313,19 @@ func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error) { switch l1v.Kind() { case reflect.Array, reflect.Slice: - ins = &intersector{r: reflect.MakeSlice(l1v.Type(), 0, 0), seen: make(map[interface{}]bool)} + ins = &intersector{r: reflect.MakeSlice(l1v.Type(), 0, 0), seen: make(map[any]bool)} switch l2v.Kind() { case reflect.Array, reflect.Slice: for i := 0; i < l1v.Len(); i++ { l1vv := l1v.Index(i) if !l1vv.Type().Comparable() { - return make([]interface{}, 0), errors.New("intersect does not support slices or arrays of uncomparable types") + return make([]any, 0), errors.New("intersect does not support slices or arrays of uncomparable types") } for j := 0; j < l2v.Len(); j++ { l2vv := l2v.Index(j) if !l2vv.Type().Comparable() { - return make([]interface{}, 0), errors.New("intersect does not support slices or arrays of uncomparable types") + return make([]any, 0), errors.New("intersect does not support slices or arrays of uncomparable types") } ins.handleValuePair(l1vv, l2vv) @@ -342,7 +342,7 @@ func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error) { // Group groups a set of elements by the given key. // This is currently only supported for Pages. -func (ns *Namespace) Group(key interface{}, items interface{}) (interface{}, error) { +func (ns *Namespace) Group(key any, items any) (any, error) { if key == nil { return nil, errors.New("nil is not a valid key to group by") } @@ -362,7 +362,7 @@ func (ns *Namespace) Group(key interface{}, items interface{}) (interface{}, err // IsSet returns whether a given array, channel, slice, or map has a key // defined. -func (ns *Namespace) IsSet(a interface{}, key interface{}) (bool, error) { +func (ns *Namespace) IsSet(a any, key any) (bool, error) { av := reflect.ValueOf(a) kv := reflect.ValueOf(key) @@ -387,7 +387,7 @@ func (ns *Namespace) IsSet(a interface{}, key interface{}) (bool, error) { } // Last returns the last N items in a rangeable list. -func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, error) { +func (ns *Namespace) Last(limit any, seq any) (any, error) { if limit == nil || seq == nil { return nil, errors.New("both limit and seq must be provided") } @@ -422,7 +422,7 @@ func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, erro } // Querify encodes the given parameters in URL-encoded form ("bar=baz&foo=quux") sorted by key. -func (ns *Namespace) Querify(params ...interface{}) (string, error) { +func (ns *Namespace) Querify(params ...any) (string, error) { qs := url.Values{} if len(params) == 1 { @@ -438,7 +438,7 @@ func (ns *Namespace) Querify(params ...interface{}) (string, error) { return qs.Encode(), nil - case []interface{}: + case []any: params = v default: @@ -463,7 +463,7 @@ func (ns *Namespace) Querify(params ...interface{}) (string, error) { } // Reverse creates a copy of slice and reverses it. -func (ns *Namespace) Reverse(slice interface{}) (interface{}, error) { +func (ns *Namespace) Reverse(slice any) (any, error) { if slice == nil { return nil, nil } @@ -493,7 +493,7 @@ func (ns *Namespace) Reverse(slice interface{}) (interface{}, error) { // -3 => -1, -2, -3 // 1 4 => 1, 2, 3, 4 // 1 -2 => 1, 0, -1, -2 -func (ns *Namespace) Seq(args ...interface{}) ([]int, error) { +func (ns *Namespace) Seq(args ...any) ([]int, error) { if len(args) < 1 || len(args) > 3 { return nil, errors.New("invalid number of arguments to Seq") } @@ -561,7 +561,7 @@ func (ns *Namespace) Seq(args ...interface{}) ([]int, error) { } // Shuffle returns the given rangeable list in a randomised order. -func (ns *Namespace) Shuffle(seq interface{}) (interface{}, error) { +func (ns *Namespace) Shuffle(seq any) (any, error) { if seq == nil { return nil, errors.New("both count and seq must be provided") } @@ -591,7 +591,7 @@ func (ns *Namespace) Shuffle(seq interface{}) (interface{}, error) { } // Slice returns a slice of all passed arguments. -func (ns *Namespace) Slice(args ...interface{}) interface{} { +func (ns *Namespace) Slice(args ...any) any { if len(args) == 0 { return args } @@ -601,7 +601,7 @@ func (ns *Namespace) Slice(args ...interface{}) interface{} { type intersector struct { r reflect.Value - seen map[interface{}]bool + seen map[any]bool } func (i *intersector) appendIfNotSeen(v reflect.Value) { @@ -638,9 +638,9 @@ func (i *intersector) handleValuePair(l1vv, l2vv reflect.Value) { // l2 must be of the same type and may be either arrays or slices. // If l1 and l2 aren't of the same type then l1 will be returned. // If either l1 or l2 is nil then the non-nil list will be returned. -func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) { +func (ns *Namespace) Union(l1, l2 any) (any, error) { if l1 == nil && l2 == nil { - return []interface{}{}, nil + return []any{}, nil } else if l1 == nil && l2 != nil { return l2, nil } else if l1 != nil && l2 == nil { @@ -656,7 +656,7 @@ func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) { case reflect.Array, reflect.Slice: switch l2v.Kind() { case reflect.Array, reflect.Slice: - ins = &intersector{r: reflect.MakeSlice(l1v.Type(), 0, 0), seen: make(map[interface{}]bool)} + ins = &intersector{r: reflect.MakeSlice(l1v.Type(), 0, 0), seen: make(map[any]bool)} if l1v.Type() != l2v.Type() && l1v.Type().Elem().Kind() != reflect.Interface && @@ -673,7 +673,7 @@ func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) { l1vv, isNil = indirectInterface(l1v.Index(i)) if !l1vv.Type().Comparable() { - return []interface{}{}, errors.New("union does not support slices or arrays of uncomparable types") + return []any{}, errors.New("union does not support slices or arrays of uncomparable types") } if !isNil { @@ -721,9 +721,9 @@ func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) { // Uniq takes in a slice or array and returns a slice with subsequent // duplicate elements removed. -func (ns *Namespace) Uniq(seq interface{}) (interface{}, error) { +func (ns *Namespace) Uniq(seq any) (any, error) { if seq == nil { - return make([]interface{}, 0), nil + return make([]any, 0), nil } v := reflect.ValueOf(seq) @@ -739,7 +739,7 @@ func (ns *Namespace) Uniq(seq interface{}) (interface{}, error) { return nil, errors.Errorf("type %T not supported", seq) } - seen := make(map[interface{}]bool) + seen := make(map[any]bool) for i := 0; i < v.Len(); i++ { ev, _ := indirectInterface(v.Index(i)) @@ -756,7 +756,7 @@ func (ns *Namespace) Uniq(seq interface{}) (interface{}, error) { } // KeyVals creates a key and values wrapper. -func (ns *Namespace) KeyVals(key interface{}, vals ...interface{}) (types.KeyValues, error) { +func (ns *Namespace) KeyVals(key any, vals ...any) (types.KeyValues, error) { return types.KeyValues{Key: key, Values: vals}, nil } diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go index 8cced6fe5..3aadfae3b 100644 --- a/tpl/collections/collections_test.go +++ b/tpl/collections/collections_test.go @@ -43,9 +43,9 @@ func TestAfter(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - index interface{} - seq interface{} - expect interface{} + index any + seq any + expect any }{ {int(2), []string{"a", "b", "c", "d"}, []string{"c", "d"}}, {int32(3), []string{"a", "b"}, []string{}}, @@ -81,7 +81,7 @@ type tstGrouper struct { type tstGroupers []*tstGrouper -func (g tstGrouper) Group(key interface{}, items interface{}) (interface{}, error) { +func (g tstGrouper) Group(key any, items any) (any, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } @@ -89,7 +89,7 @@ func (g tstGrouper) Group(key interface{}, items interface{}) (interface{}, erro type tstGrouper2 struct { } -func (g *tstGrouper2) Group(key interface{}, items interface{}) (interface{}, error) { +func (g *tstGrouper2) Group(key any, items any) (any, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } @@ -100,9 +100,9 @@ func TestGroup(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - key interface{} - items interface{} - expect interface{} + key any + items any + expect any }{ {"a", []*tstGrouper{{}, {}}, "a(2)"}, {"b", tstGroupers{&tstGrouper{}, &tstGrouper{}}, "b(2)"}, @@ -136,9 +136,9 @@ func TestDelimit(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - seq interface{} - delimiter interface{} - last interface{} + seq any + delimiter any + last any expect template.HTML }{ {[]string{"class1", "class2", "class3"}, " ", nil, "class1 class2 class3"}, @@ -188,19 +188,19 @@ func TestDictionary(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - values []interface{} - expect interface{} + values []any + expect any }{ - {[]interface{}{"a", "b"}, map[string]interface{}{"a": "b"}}, - {[]interface{}{[]string{"a", "b"}, "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c"}}}, + {[]any{"a", "b"}, map[string]any{"a": "b"}}, + {[]any{[]string{"a", "b"}, "c"}, map[string]any{"a": map[string]any{"b": "c"}}}, { - []interface{}{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"}, - map[string]interface{}{"a": map[string]interface{}{"b": "c", "b2": "c2"}, "b": "c"}, + []any{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"}, + map[string]any{"a": map[string]any{"b": "c", "b2": "c2"}, "b": "c"}, }, - {[]interface{}{"a", 12, "b", []int{4}}, map[string]interface{}{"a": 12, "b": []int{4}}}, + {[]any{"a", 12, "b", []int{4}}, map[string]any{"a": 12, "b": []int{4}}}, // errors - {[]interface{}{5, "b"}, false}, - {[]interface{}{"a", "b", "c"}, false}, + {[]any{5, "b"}, false}, + {[]any{"a", "b", "c"}, false}, } { i := i test := test @@ -246,9 +246,9 @@ func TestEchoParam(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - a interface{} - key interface{} - expect interface{} + a any + key any + expect any }{ {[]int{1, 2, 3}, 1, int64(2)}, {[]uint{1, 2, 3}, 1, uint64(2)}, @@ -260,7 +260,7 @@ func TestEchoParam(t *testing.T) { {map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)}, {map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"}, {map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""}, - {map[string]interface{}{"foo": nil}, "foo", ""}, + {map[string]any{"foo": nil}, "foo", ""}, {(*[]string)(nil), "bar", ""}, } { errMsg := qt.Commentf("[%d] %v", i, test) @@ -278,9 +278,9 @@ func TestFirst(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - limit interface{} - seq interface{} - expect interface{} + limit any + seq any + expect any }{ {int(2), []string{"a", "b", "c"}, []string{"a", "b"}}, {int32(3), []string{"a", "b"}, []string{"a", "b"}}, @@ -316,20 +316,20 @@ func TestIn(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - l1 interface{} - l2 interface{} + l1 any + l2 any expect bool }{ {[]string{"a", "b", "c"}, "b", true}, - {[]interface{}{"a", "b", "c"}, "b", true}, - {[]interface{}{"a", "b", "c"}, "d", false}, + {[]any{"a", "b", "c"}, "b", true}, + {[]any{"a", "b", "c"}, "d", false}, {[]string{"a", "b", "c"}, "d", false}, {[]string{"a", "12", "c"}, 12, false}, {[]string{"a", "b", "c"}, nil, false}, {[]int{1, 2, 4}, 2, true}, - {[]interface{}{1, 2, 4}, 2, true}, - {[]interface{}{1, 2, 4}, nil, false}, - {[]interface{}{nil}, nil, false}, + {[]any{1, 2, 4}, 2, true}, + {[]any{1, 2, 4}, nil, false}, + {[]any{nil}, nil, false}, {[]int{1, 2, 4}, 3, false}, {[]float64{1.23, 2.45, 4.67}, 1.23, true}, {[]float64{1.234567, 2.45, 4.67}, 1.234568, false}, @@ -392,16 +392,16 @@ func TestIntersect(t *testing.T) { ns := New(&deps.Deps{}) for i, test := range []struct { - l1, l2 interface{} - expect interface{} + l1, l2 any + expect any }{ {[]string{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []string{"a", "b"}}, {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"a", "b"}}, {[]string{"a", "b", "c"}, []string{"d", "e"}, []string{}}, {[]string{}, []string{}, []string{}}, - {[]string{"a", "b"}, nil, []interface{}{}}, - {nil, []string{"a", "b"}, []interface{}{}}, - {nil, nil, []interface{}{}}, + {[]string{"a", "b"}, nil, []any{}}, + {nil, []string{"a", "b"}, []any{}}, + {nil, nil, []any{}}, {[]string{"1", "2"}, []int{1, 2}, []string{}}, {[]int{1, 2}, []string{"1", "2"}, []int{}}, {[]int{1, 2, 4}, []int{2, 4}, []int{2, 4}}, @@ -410,45 +410,45 @@ func TestIntersect(t *testing.T) { {[]float64{2.2, 4.4}, []float64{1.1, 2.2, 4.4}, []float64{2.2, 4.4}}, // []interface{} ∩ []interface{} - {[]interface{}{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b"}}, - {[]interface{}{1, 2, 3}, []interface{}{1, 2, 2}, []interface{}{1, 2}}, - {[]interface{}{int8(1), int8(2), int8(3)}, []interface{}{int8(1), int8(2), int8(2)}, []interface{}{int8(1), int8(2)}}, - {[]interface{}{int16(1), int16(2), int16(3)}, []interface{}{int16(1), int16(2), int16(2)}, []interface{}{int16(1), int16(2)}}, - {[]interface{}{int32(1), int32(2), int32(3)}, []interface{}{int32(1), int32(2), int32(2)}, []interface{}{int32(1), int32(2)}}, - {[]interface{}{int64(1), int64(2), int64(3)}, []interface{}{int64(1), int64(2), int64(2)}, []interface{}{int64(1), int64(2)}}, - {[]interface{}{float32(1), float32(2), float32(3)}, []interface{}{float32(1), float32(2), float32(2)}, []interface{}{float32(1), float32(2)}}, - {[]interface{}{float64(1), float64(2), float64(3)}, []interface{}{float64(1), float64(2), float64(2)}, []interface{}{float64(1), float64(2)}}, + {[]any{"a", "b", "c"}, []any{"a", "b", "b"}, []any{"a", "b"}}, + {[]any{1, 2, 3}, []any{1, 2, 2}, []any{1, 2}}, + {[]any{int8(1), int8(2), int8(3)}, []any{int8(1), int8(2), int8(2)}, []any{int8(1), int8(2)}}, + {[]any{int16(1), int16(2), int16(3)}, []any{int16(1), int16(2), int16(2)}, []any{int16(1), int16(2)}}, + {[]any{int32(1), int32(2), int32(3)}, []any{int32(1), int32(2), int32(2)}, []any{int32(1), int32(2)}}, + {[]any{int64(1), int64(2), int64(3)}, []any{int64(1), int64(2), int64(2)}, []any{int64(1), int64(2)}}, + {[]any{float32(1), float32(2), float32(3)}, []any{float32(1), float32(2), float32(2)}, []any{float32(1), float32(2)}}, + {[]any{float64(1), float64(2), float64(3)}, []any{float64(1), float64(2), float64(2)}, []any{float64(1), float64(2)}}, // []interface{} ∩ []T - {[]interface{}{"a", "b", "c"}, []string{"a", "b", "b"}, []interface{}{"a", "b"}}, - {[]interface{}{1, 2, 3}, []int{1, 2, 2}, []interface{}{1, 2}}, - {[]interface{}{int8(1), int8(2), int8(3)}, []int8{1, 2, 2}, []interface{}{int8(1), int8(2)}}, - {[]interface{}{int16(1), int16(2), int16(3)}, []int16{1, 2, 2}, []interface{}{int16(1), int16(2)}}, - {[]interface{}{int32(1), int32(2), int32(3)}, []int32{1, 2, 2}, []interface{}{int32(1), int32(2)}}, - {[]interface{}{int64(1), int64(2), int64(3)}, []int64{1, 2, 2}, []interface{}{int64(1), int64(2)}}, - {[]interface{}{uint(1), uint(2), uint(3)}, []uint{1, 2, 2}, []interface{}{uint(1), uint(2)}}, - {[]interface{}{float32(1), float32(2), float32(3)}, []float32{1, 2, 2}, []interface{}{float32(1), float32(2)}}, - {[]interface{}{float64(1), float64(2), float64(3)}, []float64{1, 2, 2}, []interface{}{float64(1), float64(2)}}, + {[]any{"a", "b", "c"}, []string{"a", "b", "b"}, []any{"a", "b"}}, + {[]any{1, 2, 3}, []int{1, 2, 2}, []any{1, 2}}, + {[]any{int8(1), int8(2), int8(3)}, []int8{1, 2, 2}, []any{int8(1), int8(2)}}, + {[]any{int16(1), int16(2), int16(3)}, []int16{1, 2, 2}, []any{int16(1), int16(2)}}, + {[]any{int32(1), int32(2), int32(3)}, []int32{1, 2, 2}, []any{int32(1), int32(2)}}, + {[]any{int64(1), int64(2), int64(3)}, []int64{1, 2, 2}, []any{int64(1), int64(2)}}, + {[]any{uint(1), uint(2), uint(3)}, []uint{1, 2, 2}, []any{uint(1), uint(2)}}, + {[]any{float32(1), float32(2), float32(3)}, []float32{1, 2, 2}, []any{float32(1), float32(2)}}, + {[]any{float64(1), float64(2), float64(3)}, []float64{1, 2, 2}, []any{float64(1), float64(2)}}, // []T ∩ []interface{} - {[]string{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []string{"a", "b"}}, - {[]int{1, 2, 3}, []interface{}{1, 2, 2}, []int{1, 2}}, - {[]int8{1, 2, 3}, []interface{}{int8(1), int8(2), int8(2)}, []int8{1, 2}}, - {[]int16{1, 2, 3}, []interface{}{int16(1), int16(2), int16(2)}, []int16{1, 2}}, - {[]int32{1, 2, 3}, []interface{}{int32(1), int32(2), int32(2)}, []int32{1, 2}}, - {[]int64{1, 2, 3}, []interface{}{int64(1), int64(2), int64(2)}, []int64{1, 2}}, - {[]float32{1, 2, 3}, []interface{}{float32(1), float32(2), float32(2)}, []float32{1, 2}}, - {[]float64{1, 2, 3}, []interface{}{float64(1), float64(2), float64(2)}, []float64{1, 2}}, + {[]string{"a", "b", "c"}, []any{"a", "b", "b"}, []string{"a", "b"}}, + {[]int{1, 2, 3}, []any{1, 2, 2}, []int{1, 2}}, + {[]int8{1, 2, 3}, []any{int8(1), int8(2), int8(2)}, []int8{1, 2}}, + {[]int16{1, 2, 3}, []any{int16(1), int16(2), int16(2)}, []int16{1, 2}}, + {[]int32{1, 2, 3}, []any{int32(1), int32(2 |