diff options
| author | Alan Donovan <adonovan@google.com> | 2025-11-11 14:48:22 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-11 19:59:40 -0800 |
| commit | 4bfc3a9d14c0b3bfcfe4ce987e47cda6720785a2 (patch) | |
| tree | 0cbf1ec55d3a61af8bf45ac4a00af7e7bcc426db /src/reflect | |
| parent | 2263d4aabdde8a4a466009ecc356501f87c7efb7 (diff) | |
| download | go-4bfc3a9d14c0b3bfcfe4ce987e47cda6720785a2.tar.xz | |
std,cmd: go fix -any std cmd
This change mechanically replaces all occurrences of interface{}
by 'any' (where deemed safe by the 'any' modernizer) throughout
std and cmd, minus their vendor trees.
Since this fix is relatively numerous, it gets its own CL.
Also, 'go generate go/types'.
Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/719702
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/reflect')
| -rw-r--r-- | src/reflect/all_test.go | 30 | ||||
| -rw-r--r-- | src/reflect/type_test.go | 2 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 1fa850a275..8509f00a5e 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -8096,11 +8096,11 @@ func TestValue_Len(t *testing.T) { func TestValue_Comparable(t *testing.T) { var a int var s []int - var i interface{} = a - var iNil interface{} - var iSlice interface{} = s - var iArrayFalse interface{} = [2]interface{}{1, map[int]int{}} - var iArrayTrue interface{} = [2]interface{}{1, struct{ I interface{} }{1}} + var i any = a + var iNil any + var iSlice any = s + var iArrayFalse any = [2]any{1, map[int]int{}} + var iArrayTrue any = [2]any{1, struct{ I any }{1}} var testcases = []struct { value Value comparable bool @@ -8237,22 +8237,22 @@ func TestValue_Comparable(t *testing.T) { false, }, { - ValueOf([2]struct{ I interface{} }{{1}, {1}}), + ValueOf([2]struct{ I any }{{1}, {1}}), true, false, }, { - ValueOf([2]struct{ I interface{} }{{[]int{}}, {1}}), + ValueOf([2]struct{ I any }{{[]int{}}, {1}}), false, false, }, { - ValueOf([2]interface{}{1, struct{ I int }{1}}), + ValueOf([2]any{1, struct{ I int }{1}}), true, false, }, { - ValueOf([2]interface{}{[1]interface{}{map[int]int{}}, struct{ I int }{1}}), + ValueOf([2]any{[1]any{map[int]int{}}, struct{ I int }{1}}), false, false, }, @@ -8286,10 +8286,10 @@ type ValueEqualTest struct { vDeref, uDeref bool } -var equalI interface{} = 1 -var equalSlice interface{} = []int{1} -var nilInterface interface{} -var mapInterface interface{} = map[int]int{} +var equalI any = 1 +var equalSlice any = []int{1} +var nilInterface any +var mapInterface any = map[int]int{} var valueEqualTests = []ValueEqualTest{ { @@ -8468,8 +8468,8 @@ func TestValue_EqualNonComparable(t *testing.T) { // Value of array is non-comparable because of non-comparable elements. ValueOf([0]map[int]int{}), ValueOf([0]func(){}), - ValueOf(([1]struct{ I interface{} }{{[]int{}}})), - ValueOf(([1]interface{}{[1]interface{}{map[int]int{}}})), + ValueOf(([1]struct{ I any }{{[]int{}}})), + ValueOf(([1]any{[1]any{map[int]int{}}})), } for _, value := range values { // Panic when reflect.Value.Equal using two valid non-comparable values. diff --git a/src/reflect/type_test.go b/src/reflect/type_test.go index fc76a4fb98..00344c6231 100644 --- a/src/reflect/type_test.go +++ b/src/reflect/type_test.go @@ -12,7 +12,7 @@ import ( func TestTypeFor(t *testing.T) { type ( mystring string - myiface interface{} + myiface any ) testcases := []struct { |
