diff options
author | Russ Cox <rsc@golang.org> | 2021-12-01 12:15:45 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-12-13 18:45:54 +0000 |
commit | 2580d0e08d5e9f979b943758d3c49877fb2324cb (patch) | |
tree | 3aafccfd81087734156a1778ce2321adf345f271 /src/sort | |
parent | 083ef5462494e81ee23316245c5d65085a3f62d9 (diff) | |
download | go-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.gz go-2580d0e08d5e9f979b943758d3c49877fb2324cb.zip |
all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata.
And adjust tests as needed.
Not reverting the changes in std that are bootstrapped,
because some of those changes would appear in API docs,
and we want to use any consistently.
Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories
when preparing the bootstrap copy.
A few files changed as a result of running gofmt -w
not because of interface{} -> any but because they
hadn't been updated for the new //go:build lines.
Fixes #49884.
Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09
Reviewed-on: https://go-review.googlesource.com/c/go/+/368254
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/sort')
-rw-r--r-- | src/sort/slice.go | 6 | ||||
-rw-r--r-- | src/sort/slice_go14.go | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/sort/slice.go b/src/sort/slice.go index 992ad1559d..ba5c2e2f3d 100644 --- a/src/sort/slice.go +++ b/src/sort/slice.go @@ -13,7 +13,7 @@ package sort // // The less function must satisfy the same requirements as // the Interface type's Less method. -func Slice(x interface{}, less func(i, j int) bool) { +func Slice(x any, less func(i, j int) bool) { rv := reflectValueOf(x) swap := reflectSwapper(x) length := rv.Len() @@ -26,7 +26,7 @@ func Slice(x interface{}, less func(i, j int) bool) { // // The less function must satisfy the same requirements as // the Interface type's Less method. -func SliceStable(x interface{}, less func(i, j int) bool) { +func SliceStable(x any, less func(i, j int) bool) { rv := reflectValueOf(x) swap := reflectSwapper(x) stable_func(lessSwap{less, swap}, rv.Len()) @@ -34,7 +34,7 @@ func SliceStable(x interface{}, less func(i, j int) bool) { // SliceIsSorted reports whether the slice x is sorted according to the provided less function. // It panics if x is not a slice. -func SliceIsSorted(x interface{}, less func(i, j int) bool) bool { +func SliceIsSorted(x any, less func(i, j int) bool) bool { rv := reflectValueOf(x) n := rv.Len() for i := n - 1; i > 0; i-- { diff --git a/src/sort/slice_go14.go b/src/sort/slice_go14.go index 5d5949f3ca..e477367618 100644 --- a/src/sort/slice_go14.go +++ b/src/sort/slice_go14.go @@ -11,7 +11,7 @@ import "reflect" var reflectValueOf = reflect.ValueOf -func reflectSwapper(x interface{}) func(int, int) { +func reflectSwapper(x any) func(int, int) { v := reflectValueOf(x) tmp := reflect.New(v.Type().Elem()).Elem() return func(i, j int) { |