From 2580d0e08d5e9f979b943758d3c49877fb2324cb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 1 Dec 2021 12:15:45 -0500 Subject: 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 Run-TryBot: Russ Cox Reviewed-by: Robert Griesemer TryBot-Result: Gopher Robot --- src/runtime/race/testdata/issue12664_test.go | 2 +- src/runtime/race/testdata/mop_test.go | 18 +++++++++--------- src/runtime/race/testdata/pool_test.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/runtime/race/testdata') diff --git a/src/runtime/race/testdata/issue12664_test.go b/src/runtime/race/testdata/issue12664_test.go index c9f790edc8..714e83d318 100644 --- a/src/runtime/race/testdata/issue12664_test.go +++ b/src/runtime/race/testdata/issue12664_test.go @@ -56,7 +56,7 @@ func TestRaceIssue12664_3(t *testing.T) { close(c) }() var r MyT - var i interface{} = r + var i any = r issue12664_3 = i.(MyT) <-c } diff --git a/src/runtime/race/testdata/mop_test.go b/src/runtime/race/testdata/mop_test.go index 5d25ed4bb6..2d093739df 100644 --- a/src/runtime/race/testdata/mop_test.go +++ b/src/runtime/race/testdata/mop_test.go @@ -255,7 +255,7 @@ func TestRaceCaseIssue6418(t *testing.T) { func TestRaceCaseType(t *testing.T) { var x, y int - var i interface{} = x + var i any = x c := make(chan int, 1) go func() { switch i.(type) { @@ -270,7 +270,7 @@ func TestRaceCaseType(t *testing.T) { func TestRaceCaseTypeBody(t *testing.T) { var x, y int - var i interface{} = &x + var i any = &x c := make(chan int, 1) go func() { switch i := i.(type) { @@ -288,8 +288,8 @@ func TestRaceCaseTypeIssue5890(t *testing.T) { // spurious extra instrumentation of the initial interface // value. var x, y int - m := make(map[int]map[int]interface{}) - m[0] = make(map[int]interface{}) + m := make(map[int]map[int]any) + m[0] = make(map[int]any) c := make(chan int, 1) go func() { switch i := m[0][1].(type) { @@ -758,7 +758,7 @@ func TestRaceStructFieldRW3(t *testing.T) { } func TestRaceEfaceWW(t *testing.T) { - var a, b interface{} + var a, b any ch := make(chan bool, 1) go func() { a = 1 @@ -810,7 +810,7 @@ func TestRaceEfaceConv(t *testing.T) { c := make(chan bool) v := 0 go func() { - go func(x interface{}) { + go func(x any) { }(v) c <- true }() @@ -1127,7 +1127,7 @@ func TestRaceRune(t *testing.T) { func TestRaceEmptyInterface1(t *testing.T) { c := make(chan bool) - var x interface{} + var x any go func() { x = nil c <- true @@ -1138,7 +1138,7 @@ func TestRaceEmptyInterface1(t *testing.T) { func TestRaceEmptyInterface2(t *testing.T) { c := make(chan bool) - var x interface{} + var x any go func() { x = &Point{} c <- true @@ -1579,7 +1579,7 @@ func TestRaceAddrExpr(t *testing.T) { func TestRaceTypeAssert(t *testing.T) { c := make(chan bool, 1) x := 0 - var i interface{} = x + var i any = x go func() { y := 0 i = y diff --git a/src/runtime/race/testdata/pool_test.go b/src/runtime/race/testdata/pool_test.go index 161f4b7c23..a96913e381 100644 --- a/src/runtime/race/testdata/pool_test.go +++ b/src/runtime/race/testdata/pool_test.go @@ -15,7 +15,7 @@ func TestRacePool(t *testing.T) { // Repeat so that at least one iteration gets reuse. for i := 0; i < 10; i++ { c := make(chan int) - p := &sync.Pool{New: func() interface{} { return make([]byte, 10) }} + p := &sync.Pool{New: func() any { return make([]byte, 10) }} x := p.Get().([]byte) x[0] = 1 p.Put(x) @@ -31,7 +31,7 @@ func TestRacePool(t *testing.T) { func TestNoRacePool(t *testing.T) { for i := 0; i < 10; i++ { - p := &sync.Pool{New: func() interface{} { return make([]byte, 10) }} + p := &sync.Pool{New: func() any { return make([]byte, 10) }} x := p.Get().([]byte) x[0] = 1 p.Put(x) -- cgit v1.3-6-g1900