aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-12-01 12:15:45 -0500
committerRuss Cox <rsc@golang.org>2021-12-13 18:45:54 +0000
commit2580d0e08d5e9f979b943758d3c49877fb2324cb (patch)
tree3aafccfd81087734156a1778ce2321adf345f271 /src/runtime
parent083ef5462494e81ee23316245c5d65085a3f62d9 (diff)
downloadgo-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/runtime')
-rw-r--r--src/runtime/abi_test.go2
-rw-r--r--src/runtime/alg.go2
-rw-r--r--src/runtime/cgo.go2
-rw-r--r--src/runtime/cgo/handle.go4
-rw-r--r--src/runtime/cgo/handle_test.go6
-rw-r--r--src/runtime/cgocall.go4
-rw-r--r--src/runtime/chan_test.go2
-rw-r--r--src/runtime/crash_test.go2
-rw-r--r--src/runtime/debug/garbage_test.go4
-rw-r--r--src/runtime/debugcall.go2
-rw-r--r--src/runtime/debuglog.go2
-rw-r--r--src/runtime/defer_test.go2
-rw-r--r--src/runtime/error.go4
-rw-r--r--src/runtime/export_debug_test.go4
-rw-r--r--src/runtime/export_debuglog_test.go18
-rw-r--r--src/runtime/export_test.go10
-rw-r--r--src/runtime/gc_test.go12
-rw-r--r--src/runtime/gcinfo_test.go28
-rw-r--r--src/runtime/hash_test.go2
-rw-r--r--src/runtime/iface.go10
-rw-r--r--src/runtime/iface_test.go16
-rw-r--r--src/runtime/internal/atomic/bench_test.go2
-rw-r--r--src/runtime/lfstack_test.go2
-rw-r--r--src/runtime/malloc_test.go12
-rw-r--r--src/runtime/map_benchmark_test.go6
-rw-r--r--src/runtime/map_test.go6
-rw-r--r--src/runtime/mbitmap.go4
-rw-r--r--src/runtime/mfinal.go6
-rw-r--r--src/runtime/mfinal_test.go16
-rw-r--r--src/runtime/mgcscavenge.go2
-rw-r--r--src/runtime/mkpreempt.go2
-rw-r--r--src/runtime/netpoll.go12
-rw-r--r--src/runtime/os_windows.go4
-rw-r--r--src/runtime/panic.go4
-rw-r--r--src/runtime/plugin.go6
-rw-r--r--src/runtime/pprof/mprof_test.go2
-rw-r--r--src/runtime/pprof/pprof.go8
-rw-r--r--src/runtime/pprof/pprof_test.go4
-rw-r--r--src/runtime/pprof/proto_test.go2
-rw-r--r--src/runtime/race/race_test.go2
-rw-r--r--src/runtime/race/testdata/issue12664_test.go2
-rw-r--r--src/runtime/race/testdata/mop_test.go18
-rw-r--r--src/runtime/race/testdata/pool_test.go4
-rw-r--r--src/runtime/runtime2.go4
-rw-r--r--src/runtime/runtime_test.go4
-rw-r--r--src/runtime/sizeof_test.go6
-rw-r--r--src/runtime/softfloat64_test.go2
-rw-r--r--src/runtime/stack.go2
-rw-r--r--src/runtime/stack_test.go2
-rw-r--r--src/runtime/syscall_windows_test.go2
-rw-r--r--src/runtime/testdata/testprog/gc.go6
-rw-r--r--src/runtime/testdata/testprog/signal.go1
-rw-r--r--src/runtime/testdata/testprog/syscalls_none.go1
-rw-r--r--src/runtime/testdata/testprogcgo/callback.go1
-rw-r--r--src/runtime/testdata/testprogcgo/catchpanic.go1
-rw-r--r--src/runtime/testdata/testprogcgo/dropm.go1
-rw-r--r--src/runtime/testdata/testprogcgo/eintr.go1
-rw-r--r--src/runtime/testdata/testprogcgo/exec.go1
-rw-r--r--src/runtime/testdata/testprogcgo/lockosthread.go1
-rw-r--r--src/runtime/testdata/testprogcgo/needmdeadlock.go1
-rw-r--r--src/runtime/testdata/testprogcgo/numgoroutine.go1
-rw-r--r--src/runtime/testdata/testprogcgo/raceprof.go1
-rw-r--r--src/runtime/testdata/testprogcgo/racesig.go1
-rw-r--r--src/runtime/testdata/testprogcgo/segv.go1
-rw-r--r--src/runtime/testdata/testprogcgo/sigstack.go1
-rw-r--r--src/runtime/testdata/testprogcgo/threadpanic.go1
-rw-r--r--src/runtime/testdata/testprogcgo/threadpprof.go3
-rw-r--r--src/runtime/testdata/testprogcgo/threadprof.go4
-rw-r--r--src/runtime/testdata/testprognet/signal.go1
-rw-r--r--src/runtime/testdata/testprognet/signalexec.go1
-rw-r--r--src/runtime/testdata/testwinlib/main.go1
-rw-r--r--src/runtime/time.go10
-rw-r--r--src/runtime/trace/annotation.go2
73 files changed, 174 insertions, 155 deletions
diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go
index 5c1f1f4067..f9e8d701ce 100644
--- a/src/runtime/abi_test.go
+++ b/src/runtime/abi_test.go
@@ -78,7 +78,7 @@ func TestFinalizerRegisterABI(t *testing.T) {
tests := []struct {
name string
- fin interface{}
+ fin any
confirmValue int
}{
{"Pointer", regFinalizerPointer, -1},
diff --git a/src/runtime/alg.go b/src/runtime/alg.go
index 978a3b85dc..5d7d1c77f4 100644
--- a/src/runtime/alg.go
+++ b/src/runtime/alg.go
@@ -290,7 +290,7 @@ func int64Hash(i uint64, seed uintptr) uintptr {
return memhash64(noescape(unsafe.Pointer(&i)), seed)
}
-func efaceHash(i interface{}, seed uintptr) uintptr {
+func efaceHash(i any, seed uintptr) uintptr {
return nilinterhash(noescape(unsafe.Pointer(&i)), seed)
}
diff --git a/src/runtime/cgo.go b/src/runtime/cgo.go
index 395d54a66e..d90468240d 100644
--- a/src/runtime/cgo.go
+++ b/src/runtime/cgo.go
@@ -42,7 +42,7 @@ var cgoHasExtraM bool
// 2) they keep the argument alive until the call site; the call is emitted after
// the end of the (presumed) use of the argument by C.
// cgoUse should not actually be called (see cgoAlwaysFalse).
-func cgoUse(interface{}) { throw("cgoUse should not be called") }
+func cgoUse(any) { throw("cgoUse should not be called") }
// cgoAlwaysFalse is a boolean value that is always false.
// The cgo-generated code says if cgoAlwaysFalse { cgoUse(p) }.
diff --git a/src/runtime/cgo/handle.go b/src/runtime/cgo/handle.go
index 726f0a396d..d711900d79 100644
--- a/src/runtime/cgo/handle.go
+++ b/src/runtime/cgo/handle.go
@@ -105,7 +105,7 @@ type Handle uintptr
//
// The intended use is to pass the returned handle to C code, which
// passes it back to Go, which calls Value.
-func NewHandle(v interface{}) Handle {
+func NewHandle(v any) Handle {
h := atomic.AddUintptr(&handleIdx, 1)
if h == 0 {
panic("runtime/cgo: ran out of handle space")
@@ -118,7 +118,7 @@ func NewHandle(v interface{}) Handle {
// Value returns the associated Go value for a valid handle.
//
// The method panics if the handle is invalid.
-func (h Handle) Value() interface{} {
+func (h Handle) Value() any {
v, ok := handles.Load(uintptr(h))
if !ok {
panic("runtime/cgo: misuse of an invalid Handle")
diff --git a/src/runtime/cgo/handle_test.go b/src/runtime/cgo/handle_test.go
index 738051a0ea..b341c8e1e4 100644
--- a/src/runtime/cgo/handle_test.go
+++ b/src/runtime/cgo/handle_test.go
@@ -13,8 +13,8 @@ func TestHandle(t *testing.T) {
v := 42
tests := []struct {
- v1 interface{}
- v2 interface{}
+ v1 any
+ v2 any
}{
{v1: v, v2: v},
{v1: &v, v2: &v},
@@ -44,7 +44,7 @@ func TestHandle(t *testing.T) {
}
siz := 0
- handles.Range(func(k, v interface{}) bool {
+ handles.Range(func(k, v any) bool {
siz++
return true
})
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go
index 694b3e66cd..a0c9560fd0 100644
--- a/src/runtime/cgocall.go
+++ b/src/runtime/cgocall.go
@@ -389,7 +389,7 @@ var racecgosync uint64 // represents possible synchronization in C code
// cgoCheckPointer checks if the argument contains a Go pointer that
// points to a Go pointer, and panics if it does.
-func cgoCheckPointer(ptr interface{}, arg interface{}) {
+func cgoCheckPointer(ptr any, arg any) {
if debug.cgocheck == 0 {
return
}
@@ -628,7 +628,7 @@ func cgoInRange(p unsafe.Pointer, start, end uintptr) bool {
// cgoCheckResult is called to check the result parameter of an
// exported Go function. It panics if the result is or contains a Go
// pointer.
-func cgoCheckResult(val interface{}) {
+func cgoCheckResult(val any) {
if debug.cgocheck == 0 {
return
}
diff --git a/src/runtime/chan_test.go b/src/runtime/chan_test.go
index 355267c5e3..9471d4596c 100644
--- a/src/runtime/chan_test.go
+++ b/src/runtime/chan_test.go
@@ -494,7 +494,7 @@ func TestSelectFairness(t *testing.T) {
func TestChanSendInterface(t *testing.T) {
type mt struct{}
m := &mt{}
- c := make(chan interface{}, 1)
+ c := make(chan any, 1)
c <- m
select {
case c <- m:
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go
index 01b1ebcdd7..9b9ab4f3e1 100644
--- a/src/runtime/crash_test.go
+++ b/src/runtime/crash_test.go
@@ -403,7 +403,7 @@ func TestRuntimePanicWithRuntimeError(t *testing.T) {
}
}
-func panicValue(fn func()) (recovered interface{}) {
+func panicValue(fn func()) (recovered any) {
defer func() {
recovered = recover()
}()
diff --git a/src/runtime/debug/garbage_test.go b/src/runtime/debug/garbage_test.go
index c3501408dd..7213bbe641 100644
--- a/src/runtime/debug/garbage_test.go
+++ b/src/runtime/debug/garbage_test.go
@@ -151,8 +151,8 @@ func TestFreeOSMemory(t *testing.T) {
}
var (
- setGCPercentBallast interface{}
- setGCPercentSink interface{}
+ setGCPercentBallast any
+ setGCPercentSink any
)
func TestSetGCPercent(t *testing.T) {
diff --git a/src/runtime/debugcall.go b/src/runtime/debugcall.go
index 005a259f28..205971c428 100644
--- a/src/runtime/debugcall.go
+++ b/src/runtime/debugcall.go
@@ -16,7 +16,7 @@ const (
)
func debugCallV2()
-func debugCallPanicked(val interface{})
+func debugCallPanicked(val any)
// debugCallCheck checks whether it is safe to inject a debugger
// function call with return PC pc. If not, it returns a string
diff --git a/src/runtime/debuglog.go b/src/runtime/debuglog.go
index 588b54d1f5..75b91c4216 100644
--- a/src/runtime/debuglog.go
+++ b/src/runtime/debuglog.go
@@ -266,7 +266,7 @@ func (l *dlogger) hex(x uint64) *dlogger {
}
//go:nosplit
-func (l *dlogger) p(x interface{}) *dlogger {
+func (l *dlogger) p(x any) *dlogger {
if !dlogEnabled {
return l
}
diff --git a/src/runtime/defer_test.go b/src/runtime/defer_test.go
index 821db0ca12..3a54951c31 100644
--- a/src/runtime/defer_test.go
+++ b/src/runtime/defer_test.go
@@ -433,7 +433,7 @@ func TestIssue43921(t *testing.T) {
}()
}
-func expect(t *testing.T, n int, err interface{}) {
+func expect(t *testing.T, n int, err any) {
if n != err {
t.Fatalf("have %v, want %v", err, n)
}
diff --git a/src/runtime/error.go b/src/runtime/error.go
index 91f83ae126..43114f092e 100644
--- a/src/runtime/error.go
+++ b/src/runtime/error.go
@@ -210,7 +210,7 @@ type stringer interface {
// printany prints an argument passed to panic.
// If panic is called with a value that has a String or Error method,
// it has already been converted into a string by preprintpanics.
-func printany(i interface{}) {
+func printany(i any) {
switch v := i.(type) {
case nil:
print("nil")
@@ -253,7 +253,7 @@ func printany(i interface{}) {
}
}
-func printanycustomtype(i interface{}) {
+func printanycustomtype(i any) {
eface := efaceOf(&i)
typestring := eface._type.string()
diff --git a/src/runtime/export_debug_test.go b/src/runtime/export_debug_test.go
index fffc99d7e5..19a9ec135f 100644
--- a/src/runtime/export_debug_test.go
+++ b/src/runtime/export_debug_test.go
@@ -22,7 +22,7 @@ import (
//
// On success, InjectDebugCall returns the panic value of fn or nil.
// If fn did not panic, its results will be available in args.
-func InjectDebugCall(gp *g, fn interface{}, regArgs *abi.RegArgs, stackArgs interface{}, tkill func(tid int) error, returnOnUnsafePoint bool) (interface{}, error) {
+func InjectDebugCall(gp *g, fn any, regArgs *abi.RegArgs, stackArgs any, tkill func(tid int) error, returnOnUnsafePoint bool) (any, error) {
if gp.lockedm == 0 {
return nil, plainError("goroutine not locked to thread")
}
@@ -96,7 +96,7 @@ type debugCallHandler struct {
regArgs *abi.RegArgs
argp unsafe.Pointer
argSize uintptr
- panic interface{}
+ panic any
handleF func(info *siginfo, ctxt *sigctxt, gp2 *g) bool
diff --git a/src/runtime/export_debuglog_test.go b/src/runtime/export_debuglog_test.go
index 8cd943b438..1a9074e646 100644
--- a/src/runtime/export_debuglog_test.go
+++ b/src/runtime/export_debuglog_test.go
@@ -14,15 +14,15 @@ const DebugLogStringLimit = debugLogStringLimit
var Dlog = dlog
-func (l *dlogger) End() { l.end() }
-func (l *dlogger) B(x bool) *dlogger { return l.b(x) }
-func (l *dlogger) I(x int) *dlogger { return l.i(x) }
-func (l *dlogger) I16(x int16) *dlogger { return l.i16(x) }
-func (l *dlogger) U64(x uint64) *dlogger { return l.u64(x) }
-func (l *dlogger) Hex(x uint64) *dlogger { return l.hex(x) }
-func (l *dlogger) P(x interface{}) *dlogger { return l.p(x) }
-func (l *dlogger) S(x string) *dlogger { return l.s(x) }
-func (l *dlogger) PC(x uintptr) *dlogger { return l.pc(x) }
+func (l *dlogger) End() { l.end() }
+func (l *dlogger) B(x bool) *dlogger { return l.b(x) }
+func (l *dlogger) I(x int) *dlogger { return l.i(x) }
+func (l *dlogger) I16(x int16) *dlogger { return l.i16(x) }
+func (l *dlogger) U64(x uint64) *dlogger { return l.u64(x) }
+func (l *dlogger) Hex(x uint64) *dlogger { return l.hex(x) }
+func (l *dlogger) P(x any) *dlogger { return l.p(x) }
+func (l *dlogger) S(x string) *dlogger { return l.s(x) }
+func (l *dlogger) PC(x uintptr) *dlogger { return l.pc(x) }
func DumpDebugLog() string {
g := getg()
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 4a03f24ded..3c8f9eb49b 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -75,7 +75,7 @@ func Netpoll(delta int64) {
})
}
-func GCMask(x interface{}) (ret []byte) {
+func GCMask(x any) (ret []byte) {
systemstack(func() {
ret = getgcmask(x)
})
@@ -218,7 +218,7 @@ func SetEnvs(e []string) { envs = e }
// For benchmarking.
-func BenchSetType(n int, x interface{}) {
+func BenchSetType(n int, x any) {
e := *efaceOf(&x)
t := e._type
var size uintptr
@@ -546,7 +546,7 @@ func MapTombstoneCheck(m map[int]int) {
// We should have a series of filled and emptyOne cells, followed by
// a series of emptyRest cells.
h := *(**hmap)(unsafe.Pointer(&m))
- i := interface{}(m)
+ i := any(m)
t := *(**maptype)(unsafe.Pointer(&i))
for x := 0; x < 1<<h.B; x++ {
@@ -1311,10 +1311,10 @@ func (c *GCController) EndCycle(bytesMarked uint64, assistTime, elapsed int64, g
c.commit(triggerRatio)
}
-var escapeSink interface{}
+var escapeSink any
//go:noinline
-func escape(x interface{}) interface{} {
+func escape(x any) any {
escapeSink = x
escapeSink = nil
return x
diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go
index d81cb3a3d5..9743dbbe2b 100644
--- a/src/runtime/gc_test.go
+++ b/src/runtime/gc_test.go
@@ -136,7 +136,7 @@ func TestGcLastTime(t *testing.T) {
}
}
-var hugeSink interface{}
+var hugeSink any
func TestHugeGCInfo(t *testing.T) {
// The test ensures that compiler can chew these huge types even on weakest machines.
@@ -457,7 +457,7 @@ func BenchmarkSetTypeNode1024Slice(b *testing.B) {
benchSetType(b, make([]Node1024, 32))
}
-func benchSetType(b *testing.B, x interface{}) {
+func benchSetType(b *testing.B, x any) {
v := reflect.ValueOf(x)
t := v.Type()
switch t.Kind() {
@@ -523,7 +523,7 @@ func TestPrintGC(t *testing.T) {
close(done)
}
-func testTypeSwitch(x interface{}) error {
+func testTypeSwitch(x any) error {
switch y := x.(type) {
case nil:
// ok
@@ -533,14 +533,14 @@ func testTypeSwitch(x interface{}) error {
return nil
}
-func testAssert(x interface{}) error {
+func testAssert(x any) error {
if y, ok := x.(error); ok {
return y
}
return nil
}
-func testAssertVar(x interface{}) error {
+func testAssertVar(x any) error {
var y, ok = x.(error)
if ok {
return y
@@ -551,7 +551,7 @@ func testAssertVar(x interface{}) error {
var a bool
//go:noinline
-func testIfaceEqual(x interface{}) {
+func testIfaceEqual(x any) {
if x == "abc" {
a = true
}
diff --git a/src/runtime/gcinfo_test.go b/src/runtime/gcinfo_test.go
index 0808b416f0..f2c88ef1ab 100644
--- a/src/runtime/gcinfo_test.go
+++ b/src/runtime/gcinfo_test.go
@@ -66,7 +66,7 @@ func TestGCInfo(t *testing.T) {
runtime.KeepAlive(x)
}
{
- var x interface{}
+ var x any
verifyGCInfo(t, "stack eface", &x, infoEface)
runtime.KeepAlive(x)
}
@@ -84,12 +84,12 @@ func TestGCInfo(t *testing.T) {
verifyGCInfo(t, "heap PtrScalar", escape(new(PtrScalar)), trimDead(infoPtrScalar))
verifyGCInfo(t, "heap BigStruct", escape(new(BigStruct)), trimDead(infoBigStruct()))
verifyGCInfo(t, "heap string", escape(new(string)), trimDead(infoString))
- verifyGCInfo(t, "heap eface", escape(new(interface{})), trimDead(infoEface))
+ verifyGCInfo(t, "heap eface", escape(new(any)), trimDead(infoEface))
verifyGCInfo(t, "heap iface", escape(new(Iface)), trimDead(infoIface))
}
}
-func verifyGCInfo(t *testing.T, name string, p interface{}, mask0 []byte) {
+func verifyGCInfo(t *testing.T, name string, p any, mask0 []byte) {
mask := runtime.GCMask(p)
if !bytes.Equal(mask, mask0) {
t.Errorf("bad GC program for %v:\nwant %+v\ngot %+v", name, mask0, mask)
@@ -104,9 +104,9 @@ func trimDead(mask []byte) []byte {
return mask
}
-var gcinfoSink interface{}
+var gcinfoSink any
-func escape(p interface{}) interface{} {
+func escape(p any) any {
gcinfoSink = p
return p
}
@@ -194,18 +194,18 @@ var (
bssBigStruct BigStruct
bssString string
bssSlice []string
- bssEface interface{}
+ bssEface any
bssIface Iface
// DATA
- dataPtr = Ptr{new(byte)}
- dataScalarPtr = ScalarPtr{q: 1}
- dataPtrScalar = PtrScalar{w: 1}
- dataBigStruct = BigStruct{w: 1}
- dataString = "foo"
- dataSlice = []string{"foo"}
- dataEface interface{} = 42
- dataIface Iface = IfaceImpl(42)
+ dataPtr = Ptr{new(byte)}
+ dataScalarPtr = ScalarPtr{q: 1}
+ dataPtrScalar = PtrScalar{w: 1}
+ dataBigStruct = BigStruct{w: 1}
+ dataString = "foo"
+ dataSlice = []string{"foo"}
+ dataEface any = 42
+ dataIface Iface = IfaceImpl(42)
infoString = []byte{typePointer, typeScalar}
infoSlice = []byte{typePointer, typeScalar, typeScalar}
diff --git a/src/runtime/hash_test.go b/src/runtime/hash_test.go
index 7048874a71..cf56c57a5f 100644
--- a/src/runtime/hash_test.go
+++ b/src/runtime/hash_test.go
@@ -382,7 +382,7 @@ func (k *Int64Key) name() string {
}
type EfaceKey struct {
- i interface{}
+ i any
}
func (k *EfaceKey) clear() {
diff --git a/src/runtime/iface.go b/src/runtime/iface.go
index e2bec10948..a4d56dd33b 100644
--- a/src/runtime/iface.go
+++ b/src/runtime/iface.go
@@ -296,11 +296,11 @@ type (
)
var (
- uint16Eface interface{} = uint16InterfacePtr(0)
- uint32Eface interface{} = uint32InterfacePtr(0)
- uint64Eface interface{} = uint64InterfacePtr(0)
- stringEface interface{} = stringInterfacePtr("")
- sliceEface interface{} = sliceInterfacePtr(nil)
+ uint16Eface any = uint16InterfacePtr(0)
+ uint32Eface any = uint32InterfacePtr(0)
+ uint64Eface any = uint64InterfacePtr(0)
+ stringEface any = stringInterfacePtr("")
+ sliceEface any = sliceInterfacePtr(nil)
uint16Type *_type = efaceOf(&uint16Eface)._type
uint32Type *_type = efaceOf(&uint32Eface)._type
diff --git a/src/runtime/iface_test.go b/src/runtime/iface_test.go
index 4fab6c968a..06f6eeb952 100644
--- a/src/runtime/iface_test.go
+++ b/src/runtime/iface_test.go
@@ -44,8 +44,8 @@ func (Tstr) Method1() {}
func (Tslice) Method1() {}
var (
- e interface{}
- e_ interface{}
+ e any
+ e_ any
i1 I1
i2 I2
ts TS
@@ -196,7 +196,7 @@ func BenchmarkAssertI2I(b *testing.B) {
func BenchmarkAssertI2E(b *testing.B) {
i1 = tm
for i := 0; i < b.N; i++ {
- e = i1.(interface{})
+ e = i1.(any)
}
}
@@ -224,33 +224,33 @@ func BenchmarkAssertE2T2Blank(b *testing.B) {
func BenchmarkAssertI2E2(b *testing.B) {
i1 = tm
for i := 0; i < b.N; i++ {
- e, ok = i1.(interface{})
+ e, ok = i1.(any)
}
}
func BenchmarkAssertI2E2Blank(b *testing.B) {
i1 = tm
for i := 0; i < b.N; i++ {
- _, ok = i1.(interface{})
+ _, ok = i1.(any)
}
}
func BenchmarkAssertE2E2(b *testing.B) {
e = tm
for i := 0; i < b.N; i++ {
- e_, ok = e.(interface{})
+ e_, ok = e.(any)
}
}
func BenchmarkAssertE2E2Blank(b *testing.B) {
e = tm
for i := 0; i < b.N; i++ {
- _, ok = e.(interface{})
+ _, ok = e.(any)
}
}
func TestNonEscapingConvT2E(t *testing.T) {
- m := make(map[interface{}]bool)
+ m := make(map[any]bool)
m[42] = true
if !m[42] {
t.Fatalf("42 is not present in the map")
diff --git a/src/runtime/internal/atomic/bench_test.go b/src/runtime/internal/atomic/bench_test.go
index 2476c06c52..efc0531a0d 100644
--- a/src/runtime/internal/atomic/bench_test.go
+++ b/src/runtime/internal/atomic/bench_test.go
@@ -9,7 +9,7 @@ import (
"testing"
)
-var sink interface{}
+var sink any
func BenchmarkAtomicLoad64(b *testing.B) {
var x uint64
diff --git a/src/runtime/lfstack_test.go b/src/runtime/lfstack_test.go
index fb4b45992d..d0a1b6ba06 100644
--- a/src/runtime/lfstack_test.go
+++ b/src/runtime/lfstack_test.go
@@ -24,7 +24,7 @@ func toMyNode(node *LFNode) *MyNode {
return (*MyNode)(unsafe.Pointer(node))
}
-var global interface{}
+var global any
func TestLFStack(t *testing.T) {
stack := new(uint64)
diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go
index 757f945393..8ff88687bd 100644
--- a/src/runtime/malloc_test.go
+++ b/src/runtime/malloc_test.go
@@ -33,14 +33,14 @@ func TestMemStats(t *testing.T) {
st := new(MemStats)
ReadMemStats(st)
- nz := func(x interface{}) error {
+ nz := func(x any) error {
if x != reflect.Zero(reflect.TypeOf(x)).Interface() {
return nil
}
return fmt.Errorf("zero value")
}
- le := func(thresh float64) func(interface{}) error {
- return func(x interface{}) error {
+ le := func(thresh float64) func(any) error {
+ return func(x any) error {
// These sanity tests aren't necessarily valid
// with high -test.count values, so only run
// them once.
@@ -54,8 +54,8 @@ func TestMemStats(t *testing.T) {
return fmt.Errorf("insanely high value (overflow?); want <= %v", thresh)
}
}
- eq := func(x interface{}) func(interface{}) error {
- return func(y interface{}) error {
+ eq := func(x any) func(any) error {
+ return func(y any) error {
if x == y {
return nil
}
@@ -64,7 +64,7 @@ func TestMemStats(t *testing.T) {
}
// Of the uint fields, HeapReleased, HeapIdle can be 0.
// PauseTotalNs can be 0 if timer resolution is poor.
- fields := map[string][]func(interface{}) error{
+ fields := map[string][]func(any) error{
"Alloc": {nz, le(1e10)}, "TotalAlloc": {nz, le(1e11)}, "Sys": {nz, le(1e10)},
"Lookups": {eq(uint64(0))}, "Mallocs": {nz, le(1e10)}, "Frees": {nz, le(1e10)},
"HeapAlloc": {nz, le(1e10)}, "HeapSys": {nz, le(1e10)}, "HeapIdle": {le(1e10)},
diff --git a/src/runtime/map_benchmark_test.go b/src/runtime/map_benchmark_test.go
index d0becc9ddb..b46d2a4727 100644
--- a/src/runtime/map_benchmark_test.go
+++ b/src/runtime/map_benchmark_test.go
@@ -488,20 +488,20 @@ func BenchmarkMapStringConversion(b *testing.B) {
var BoolSink bool
func BenchmarkMapInterfaceString(b *testing.B) {
- m := map[interface{}]bool{}
+ m := map[any]bool{}
for i := 0; i < 100; i++ {
m[fmt.Sprintf("%d", i)] = true
}
- key := (interface{})("A")
+ key := (any)("A")
b.ResetTimer()
for i := 0; i < b.N; i++ {
BoolSink = m[key]
}
}
func BenchmarkMapInterfacePtr(b *testing.B) {
- m := map[interface{}]bool{}
+ m := map[any]bool{}
for i := 0; i < 100; i++ {
i := i
diff --git a/src/runtime/map_test.go b/src/runtime/map_test.go
index f78cad5a77..0c83dd4ddf 100644
--- a/src/runtime/map_test.go
+++ b/src/runtime/map_test.go
@@ -1050,7 +1050,7 @@ func BenchmarkMapDelete(b *testing.B) {
func TestDeferDeleteSlow(t *testing.T) {
ks := []complex128{0, 1, 2, 3}
- m := make(map[interface{}]int)
+ m := make(map[any]int)
for i, k := range ks {
m[k] = i
}
@@ -1193,14 +1193,14 @@ func TestMapInterfaceKey(t *testing.T) {
c64 complex64
c128 complex128
s string
- i0 interface{}
+ i0 any
i1 interface {
String() string
}
a [4]string
}
- m := map[interface{}]bool{}
+ m := map[any]bool{}
// Put a bunch of data in m, so that a bad hash is likely to
// lead to a bad bucket, which will lead to a missed lookup.
for i := 0; i < 1000; i++ {
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index 3330ddd62e..1c6f3f959f 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -1952,7 +1952,7 @@ func getgcmaskcb(frame *stkframe, ctxt unsafe.Pointer) bool {
// gcbits returns the GC type info for x, for testing.
// The result is the bitmap entries (0 or 1), one entry per byte.
//go:linkname reflect_gcbits reflect.gcbits
-func reflect_gcbits(x interface{}) []byte {
+func reflect_gcbits(x any) []byte {
ret := getgcmask(x)
typ := (*ptrtype)(unsafe.Pointer(efaceOf(&x)._type)).elem
nptr := typ.ptrdata / goarch.PtrSize
@@ -1965,7 +1965,7 @@ func reflect_gcbits(x interface{}) []byte {
// Returns GC type info for the pointer stored in ep for testing.
// If ep points to the stack, only static live information will be returned
// (i.e. not for objects which are only dynamically live stack objects).
-func getgcmask(ep interface{}) (mask []byte) {
+func getgcmask(ep any) (mask []byte) {
e := *efaceOf(&ep)
p := e.data
t := e._type
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go
index 3cdb81e2fb..e2ac5d4993 100644
--- a/src/runtime/mfinal.go
+++ b/src/runtime/mfinal.go
@@ -200,7 +200,7 @@ func runfinq() {
framesz = f.nret
} else {
// Need to pass arguments on the stack too.
- framesz = unsafe.Sizeof((interface{})(nil)) + f.nret
+ framesz = unsafe.Sizeof((any)(nil)) + f.nret
}
if framecap < framesz {
// The frame does not contain pointers interesting for GC,
@@ -329,7 +329,7 @@ func runfinq() {
// A single goroutine runs all finalizers for a program, sequentially.
// If a finalizer must run for a long time, it should do so by starting
// a new goroutine.
-func SetFinalizer(obj interface{}, finalizer interface{}) {
+func SetFinalizer(obj any, finalizer any) {
if debug.sbrk != 0 {
// debug.sbrk never frees memory, so no finalizers run
// (and we don't have the data structures to record them).
@@ -470,7 +470,7 @@ okarg:
// Note: KeepAlive should only be used to prevent finalizers from
// running prematurely. In particular, when used with unsafe.Pointer,
// the rules for valid uses of unsafe.Pointer still apply.
-func KeepAlive(x interface{}) {
+func KeepAlive(x any) {
// Introduce a use of x that the compiler can't eliminate.
// This makes sure x is alive on entry. We need x to be alive
// on entry for "defer runtime.KeepAlive(x)"; see issue 21402.
diff --git a/src/runtime/mfinal_test.go b/src/runtime/mfinal_test.go
index 3ca8d31c60..04ba7a6830 100644
--- a/src/runtime/mfinal_test.go
+++ b/src/runtime/mfinal_test.go
@@ -34,14 +34,14 @@ func TestFinalizerType(t *testing.T) {
}
var finalizerTests = []struct {
- convert func(*int) interface{}
- finalizer interface{}
+ convert func(*int) any
+ finalizer any
}{
- {func(x *int) interface{} { return x }, func(v *int) { finalize(v) }},
- {func(x *int) interface{} { return Tintptr(x) }, func(v Tintptr) { finalize(v) }},
- {func(x *int) interface{} { return Tintptr(x) }, func(v *int) { finalize(v) }},
- {func(x *int) interface{} { return (*Tint)(x) }, func(v *Tint) { finalize((*int)(v)) }},
- {func(x *int) interface{} { return (*Tint)(x) }, func(v Tinter) { finalize((*int)(v.(*Tint))) }},
+ {func(x *int) any { return x }, func(v *int) { finalize(v) }},
+ {func(x *int) any { return Tintptr(x) }, func(v Tintptr) { finalize(v) }},
+ {func(x *int) any { return Tintptr(x) }, func(v *int) { finalize(v) }},
+ {func(x *int) any { return (*Tint)(x) }, func(v *Tint) { finalize((*int)(v)) }},
+ {func(x *int) any { return (*Tint)(x) }, func(v Tinter) { finalize((*int)(v.(*Tint))) }},
}
for i, tt := range finalizerTests {
@@ -85,7 +85,7 @@ func TestFinalizerInterfaceBig(t *testing.T) {
go func() {
v := &bigValue{0xDEADBEEFDEADBEEF, true, "It matters not how strait the gate"}
old := *v
- runtime.SetFinalizer(v, func(v interface{}) {
+ runtime.SetFinalizer(v, func(v any) {
i, ok := v.(*bigValue)
if !ok {
t.Errorf("finalizer called with type %T, want *bigValue", v)
diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go
index 0399c2d21c..c27e189af9 100644
--- a/src/runtime/mgcscavenge.go
+++ b/src/runtime/mgcscavenge.go
@@ -263,7 +263,7 @@ func bgscavenge(c chan int) {
scavenge.parked = true
scavenge.timer = new(timer)
- scavenge.timer.f = func(_ interface{}, _ uintptr) {
+ scavenge.timer.f = func(_ any, _ uintptr) {
wakeScavenger()
}
diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go
index e8c23d485a..17c9b75d69 100644
--- a/src/runtime/mkpreempt.go
+++ b/src/runtime/mkpreempt.go
@@ -129,7 +129,7 @@ func header(arch string) {
fmt.Fprintf(out, "TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0\n")
}
-func p(f string, args ...interface{}) {
+func p(f string, args ...any) {
fmted := fmt.Sprintf(f, args...)
fmt.Fprintf(out, "\t%s\n", strings.ReplaceAll(fmted, "\n", "\n\t"))
}
diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go
index f60e62dec7..322a6f3637 100644
--- a/src/runtime/netpoll.go
+++ b/src/runtime/netpoll.go
@@ -529,15 +529,15 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) {
}
}
-func netpollDeadline(arg interface{}, seq uintptr) {
+func netpollDeadline(arg any, seq uintptr) {
netpolldeadlineimpl(arg.(*pollDesc), seq, true, true)
}
-func netpollReadDeadline(arg interface{}, seq uintptr) {
+func netpollReadDeadline(arg any, seq uintptr) {
netpolldeadlineimpl(arg.(*pollDesc), seq, true, false)
}
-func netpollWriteDeadline(arg interface{}, seq uintptr) {
+func netpollWriteDeadline(arg any, seq uintptr) {
netpolldeadlineimpl(arg.(*pollDesc), seq, false, true)
}
@@ -570,7 +570,7 @@ func (c *pollCache) alloc() *pollDesc {
// a conversion requires an allocation because pointers to
// go:notinheap types (which pollDesc is) must be stored
// in interfaces indirectly. See issue 42076.
-func (pd *pollDesc) makeArg() (i interface{}) {
+func (pd *pollDesc) makeArg() (i any) {
x := (*eface)(unsafe.Pointer(&i))
x._type = pdType
x.data = unsafe.Pointer(&pd.self)
@@ -578,6 +578,6 @@ func (pd *pollDesc) makeArg() (i interface{}) {
}
var (
- pdEface interface{} = (*pollDesc)(nil)
- pdType *_type = efaceOf(&pdEface)._type
+ pdEface any = (*pollDesc)(nil)
+ pdType *_type = efaceOf(&pdEface)._type
)
diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go
index 15953ffa0c..c76add7802 100644
--- a/src/runtime/os_windows.go
+++ b/src/runtime/os_windows.go
@@ -323,7 +323,7 @@ func monitorSuspendResume() {
if powerRegisterSuspendResumeNotification == nil {
return // Running on Windows 7, where we don't need it anyway.
}
- var fn interface{} = func(context uintptr, changeType uint32, setting uintptr) uintptr {
+ var fn any = func(context uintptr, changeType uint32, setting uintptr) uintptr {
for mp := (*m)(atomic.Loadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink {
if mp.resumesema != 0 {
stdcall1(_SetEvent, mp.resumesema)
@@ -682,7 +682,7 @@ func goenvs() {
// We call these all the way here, late in init, so that malloc works
// for the callback functions these generate.
- var fn interface{} = ctrlHandler
+ var fn any = ctrlHandler
ctrlHandlerPC := compileCallback(*efaceOf(&fn), true)
stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1)
diff --git a/src/runtime/panic.go b/src/runtime/panic.go
index 3d5f4edb45..6600410cb6 100644
--- a/src/runtime/panic.go
+++ b/src/runtime/panic.go
@@ -755,7 +755,7 @@ func deferCallSave(p *_panic, fn func()) {
}
// The implementation of the predeclared function panic.
-func gopanic(e interface{}) {
+func gopanic(e any) {
gp := getg()
if gp.m.curg != gp {
print("panic: ")
@@ -957,7 +957,7 @@ func getargp() uintptr {
// TODO(rsc): Once we commit to CopyStackAlways,
// this doesn't need to be nosplit.
//go:nosplit
-func gorecover(argp uintptr) interface{} {
+func gorecover(argp uintptr) any {
// Must be in a function running as part of a deferred call during the panic.
// Must be called from the topmost function of the call
// (the function used in the defer statement).
diff --git a/src/runtime/plugin.go b/src/runtime/plugin.go
index f37854f915..a61dcc3b5d 100644
--- a/src/runtime/plugin.go
+++ b/src/runtime/plugin.go
@@ -7,7 +7,7 @@ package runtime
import "unsafe"
//go:linkname plugin_lastmoduleinit plugin.lastmoduleinit
-func plugin_lastmoduleinit() (path string, syms map[string]interface{}, errstr string) {
+func plugin_lastmoduleinit() (path string, syms map[string]any, errstr string) {
var md *moduledata
for pmd := firstmoduledata.next; pmd != nil; pmd = pmd.next {
if pmd.bad {
@@ -76,11 +76,11 @@ func plugin_lastmoduleinit() (path string, syms map[string]interface{}, errstr s
// Because functions are handled specially in the plugin package,
// function symbol names are prefixed here with '.' to avoid
// a dependency on the reflect package.
- syms = make(map[string]interface{}, len(md.ptab))
+ syms = make(map[string]any, len(md.ptab))
for _, ptab := range md.ptab {
symName := resolveNameOff(unsafe.Pointer(md.types), ptab.name)
t := (*_type)(unsafe.Pointer(md.types)).typeOff(ptab.typ)
- var val interface{}
+ var val any
valp := (*[2]unsafe.Pointer)(unsafe.Pointer(&val))
(*valp)[0] = unsafe.Pointer(t)
diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go
index ab8341d32f..665487a7c4 100644
--- a/src/runtime/pprof/mprof_test.go
+++ b/src/runtime/pprof/mprof_test.go
@@ -17,7 +17,7 @@ import (
"unsafe"
)
-var memSink interface{}
+var memSink any
func allocateTransient1M() {
for i := 0; i < 1024; i++ {
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index 000abf935c..d75efce7a8 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -134,7 +134,7 @@ import (
type Profile struct {
name string
mu sync.Mutex
- m map[interface{}][]uintptr
+ m map[any][]uintptr
count func() int
write func(io.Writer, int) error
}
@@ -217,7 +217,7 @@ func NewProfile(name string) *Profile {
}
p := &Profile{
name: name,
- m: map[interface{}][]uintptr{},
+ m: map[any][]uintptr{},
}
profiles.m[name] = p
return p
@@ -277,7 +277,7 @@ func (p *Profile) Count() int {
// Passing skip=0 begins the stack trace at the call to Add inside rpc.NewClient.
// Passing skip=1 begins the stack trace at the call to NewClient inside mypkg.Run.
//
-func (p *Profile) Add(value interface{}, skip int) {
+func (p *Profile) Add(value any, skip int) {
if p.name == "" {
panic("pprof: use of uninitialized Profile")
}
@@ -303,7 +303,7 @@ func (p *Profile) Add(value interface{}, skip int) {
// Remove removes the execution stack associated with value from the profile.
// It is a no-op if the value is not in the profile.
-func (p *Profile) Remove(value interface{}) {
+func (p *Profile) Remove(value any) {
p.mu.Lock()
defer p.mu.Unlock()
delete(p.m, value)
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index b3a8927dc7..d32046379a 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -235,14 +235,14 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) {
// containsInlinedCall reports whether the function body for the function f is
// known to contain an inlined function call within the first maxBytes bytes.
-func containsInlinedCall(f interface{}, maxBytes int) bool {
+func containsInlinedCall(f any, maxBytes int) bool {
_, found := findInlinedCall(f, maxBytes)
return found
}
// findInlinedCall returns the PC of an inlined function call within
// the function body for the function f if any.
-func findInlinedCall(f interface{}, maxBytes int) (pc uint64, found bool) {
+func findInlinedCall(f any, maxBytes int) (pc uint64, found bool) {
fFunc := runtime.FuncForPC(uintptr(abi.FuncPCABIInternal(f)))
if fFunc == nil || fFunc.Entry() == 0 {
panic("failed to locate function entry")
diff --git a/src/runtime/pprof/proto_test.go b/src/runtime/pprof/proto_test.go
index ea0ed9aefd..84a051a536 100644
--- a/src/runtime/pprof/proto_test.go
+++ b/src/runtime/pprof/proto_test.go
@@ -40,7 +40,7 @@ func translateCPUProfile(data []uint64, count int) (*profile.Profile, error) {
// fmtJSON returns a pretty-printed JSON form for x.
// It works reasonbly well for printing protocol-buffer
// data structures like profile.Profile.
-func fmtJSON(x interface{}) string {
+func fmtJSON(x any) string {
js, _ := json.MarshalIndent(x, "", "\t")
return string(js)
}
diff --git a/src/runtime/race/race_test.go b/src/runtime/race/race_test.go
index 1677e13986..4fe61683eb 100644
--- a/src/runtime/race/race_test.go
+++ b/src/runtime/race/race_test.go
@@ -187,7 +187,7 @@ func runTests(t *testing.T) ([]byte, error) {
func TestIssue8102(t *testing.T) {
// If this compiles with -race, the test passes.
type S struct {
- x interface{}
+ x any
i int
}
c := make(chan int)
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)
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index bfd857e8d5..ec34e7ac1a 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -209,7 +209,7 @@ type eface struct {
data unsafe.Pointer
}
-func efaceOf(ep *interface{}) *eface {
+func efaceOf(ep *any) *eface {
return (*eface)(unsafe.Pointer(ep))
}
@@ -982,7 +982,7 @@ type _defer struct {
// adjustment takes care of them.
type _panic struct {
argp unsafe.Pointer // pointer to arguments of deferred call run during panic; cannot move - known to liblink
- arg interface{} // argument to panic
+ arg any // argument to panic
link *_panic // link to earlier panic
pc uintptr // where to return to in runtime if this panic is bypassed
sp unsafe.Pointer // where to return to in runtime if this panic is bypassed
diff --git a/src/runtime/runtime_test.go b/src/runtime/runtime_test.go
index 4572a25195..1ca1fa2f05 100644
--- a/src/runtime/runtime_test.go
+++ b/src/runtime/runtime_test.go
@@ -53,8 +53,8 @@ func BenchmarkIfaceCmpNil100(b *testing.B) {
}
}
-var efaceCmp1 interface{}
-var efaceCmp2 interface{}
+var efaceCmp1 any
+var efaceCmp2 any
func BenchmarkEfaceCmpDiff(b *testing.B) {
x := 5
diff --git a/src/runtime/sizeof_test.go b/src/runtime/sizeof_test.go
index bbbd1becf7..ebf544ad3b 100644
--- a/src/runtime/sizeof_test.go
+++ b/src/runtime/sizeof_test.go
@@ -17,9 +17,9 @@ func TestSizeof(t *testing.T) {
const _64bit = unsafe.Sizeof(uintptr(0)) == 8
var tests = []struct {
- val interface{} // type as a value
- _32bit uintptr // size on 32bit platforms
- _64bit uintptr // size on 64bit platforms
+ val any // type as a value
+ _32bit uintptr // size on 32bit platforms
+ _64bit uintptr // size on 64bit platforms
}{
{runtime.G{}, 236, 392}, // g, but exported for testing
{runtime.Sudog{}, 56, 88}, // sudog, but exported for testing
diff --git a/src/runtime/softfloat64_test.go b/src/runtime/softfloat64_test.go
index 7347aff8f1..3f53e8bc55 100644
--- a/src/runtime/softfloat64_test.go
+++ b/src/runtime/softfloat64_test.go
@@ -127,7 +127,7 @@ func fromint64sw(f float64) float64 {
var nerr int
-func err(t *testing.T, format string, args ...interface{}) {
+func err(t *testing.T, format string, args ...any) {
t.Errorf(format, args...)
// cut errors off after a while.
diff --git a/src/runtime/stack.go b/src/runtime/stack.go
index 25a6f5bbb4..edc37d4878 100644
--- a/src/runtime/stack.go
+++ b/src/runtime/stack.go
@@ -1358,7 +1358,7 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args
var methodValueCallFrameObjs [1]stackObjectRecord // initialized in stackobjectinit
func stkobjinit() {
- var abiRegArgsEface interface{} = abi.RegArgs{}
+ var abiRegArgsEface any = abi.RegArgs{}
abiRegArgsType := efaceOf(&abiRegArgsEface)._type
if abiRegArgsType.kind&kindGCProg != 0 {
throw("abiRegArgsType needs GC Prog, update methodValueCallFrameObjs")
diff --git a/src/runtime/stack_test.go b/src/runtime/stack_test.go
index 3f02243a1e..4c2671b31f 100644
--- a/src/runtime/stack_test.go
+++ b/src/runtime/stack_test.go
@@ -879,7 +879,7 @@ func deferHeapAndStack(n int) (r int) {
}
// Pass a value to escapeMe to force it to escape.
-var escapeMe = func(x interface{}) {}
+var escapeMe = func(x any) {}
// Test that when F -> G is inlined and F is excluded from stack
// traces, G still appears.
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index 65f74b32fb..101e94107c 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -288,7 +288,7 @@ func TestCallbackInAnotherThread(t *testing.T) {
}
type cbFunc struct {
- goFunc interface{}
+ goFunc any
}
func (f cbFunc) cName(cdecl bool) string {
diff --git a/src/runtime/testdata/testprog/gc.go b/src/runtime/testdata/testprog/gc.go
index 7d371a6a89..215228ea05 100644
--- a/src/runtime/testdata/testprog/gc.go
+++ b/src/runtime/testdata/testprog/gc.go
@@ -90,7 +90,7 @@ func GCFairness2() {
runtime.GOMAXPROCS(1)
debug.SetGCPercent(1)
var count [3]int64
- var sink [3]interface{}
+ var sink [3]any
for i := range count {
go func(i int) {
for {
@@ -266,9 +266,9 @@ func DeferLiveness() {
}
//go:noinline
-func escape(x interface{}) { sink2 = x; sink2 = nil }
+func escape(x any) { sink2 = x; sink2 = nil }
-var sink2 interface{}
+var sink2 any
// Test zombie object detection and reporting.
func GCZombie() {
diff --git a/src/runtime/testdata/testprog/signal.go b/src/runtime/testdata/testprog/signal.go
index 417e105c68..cc5ac8af58 100644
--- a/src/runtime/testdata/testprog/signal.go
+++ b/src/runtime/testdata/testprog/signal.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !windows && !plan9
// +build !windows,!plan9
package main
diff --git a/src/runtime/testdata/testprog/syscalls_none.go b/src/runtime/testdata/testprog/syscalls_none.go
index 7f8ded3994..068bb59af3 100644
--- a/src/runtime/testdata/testprog/syscalls_none.go
+++ b/src/runtime/testdata/testprog/syscalls_none.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !linux
// +build !linux
package main
diff --git a/src/runtime/testdata/testprogcgo/callback.go b/src/runtime/testdata/testprogcgo/callback.go
index be0409f39d..a2d8a492a4 100644
--- a/src/runtime/testdata/testprogcgo/callback.go
+++ b/src/runtime/testdata/testprogcgo/callback.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/catchpanic.go b/src/runtime/testdata/testprogcgo/catchpanic.go
index 55a606d1bc..c722d40a19 100644
--- a/src/runtime/testdata/testprogcgo/catchpanic.go
+++ b/src/runtime/testdata/testprogcgo/catchpanic.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/dropm.go b/src/runtime/testdata/testprogcgo/dropm.go
index 9e782f504f..700b7fa0c2 100644
--- a/src/runtime/testdata/testprogcgo/dropm.go
+++ b/src/runtime/testdata/testprogcgo/dropm.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
// Test that a sequence of callbacks from C to Go get the same m.
diff --git a/src/runtime/testdata/testprogcgo/eintr.go b/src/runtime/testdata/testprogcgo/eintr.go
index 1722a75eb9..b35b280a76 100644
--- a/src/runtime/testdata/testprogcgo/eintr.go
+++ b/src/runtime/testdata/testprogcgo/eintr.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/exec.go b/src/runtime/testdata/testprogcgo/exec.go
index 15723c7369..c268bcd9b2 100644
--- a/src/runtime/testdata/testprogcgo/exec.go
+++ b/src/runtime/testdata/testprogcgo/exec.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/lockosthread.go b/src/runtime/testdata/testprogcgo/lockosthread.go
index 36423d9eb0..8fcea35f52 100644
--- a/src/runtime/testdata/testprogcgo/lockosthread.go
+++ b/src/runtime/testdata/testprogcgo/lockosthread.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/needmdeadlock.go b/src/runtime/testdata/testprogcgo/needmdeadlock.go
index 5a9c359006..b95ec77468 100644
--- a/src/runtime/testdata/testprogcgo/needmdeadlock.go
+++ b/src/runtime/testdata/testprogcgo/needmdeadlock.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/numgoroutine.go b/src/runtime/testdata/testprogcgo/numgoroutine.go
index 5bdfe52ed4..1b9f202f46 100644
--- a/src/runtime/testdata/testprogcgo/numgoroutine.go
+++ b/src/runtime/testdata/testprogcgo/numgoroutine.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/raceprof.go b/src/runtime/testdata/testprogcgo/raceprof.go
index f7ca629789..c098e16196 100644
--- a/src/runtime/testdata/testprogcgo/raceprof.go
+++ b/src/runtime/testdata/testprogcgo/raceprof.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build (linux && amd64) || (freebsd && amd64)
// +build linux,amd64 freebsd,amd64
package main
diff --git a/src/runtime/testdata/testprogcgo/racesig.go b/src/runtime/testdata/testprogcgo/racesig.go
index a079b3fd1a..9352679714 100644
--- a/src/runtime/testdata/testprogcgo/racesig.go
+++ b/src/runtime/testdata/testprogcgo/racesig.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build (linux && amd64) || (freebsd && amd64)
// +build linux,amd64 freebsd,amd64
package main
diff --git a/src/runtime/testdata/testprogcgo/segv.go b/src/runtime/testdata/testprogcgo/segv.go
index 3237a8c69c..0632475228 100644
--- a/src/runtime/testdata/testprogcgo/segv.go
+++ b/src/runtime/testdata/testprogcgo/segv.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
diff --git a/src/runtime/testdata/testprogcgo/sigstack.go b/src/runtime/testdata/testprogcgo/sigstack.go
index 21b668d6c0..12ca661033 100644
--- a/src/runtime/testdata/testprogcgo/sigstack.go
+++ b/src/runtime/testdata/testprogcgo/sigstack.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
// Test handling of Go-allocated signal stacks when calling from
diff --git a/src/runtime/testdata/testprogcgo/threadpanic.go b/src/runtime/testdata/testprogcgo/threadpanic.go
index f9b48a9026..2d24fe68ea 100644
--- a/src/runtime/testdata/testprogcgo/threadpanic.go
+++ b/src/runtime/testdata/testprogcgo/threadpanic.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9
// +build !plan9
package main
diff --git a/src/runtime/testdata/testprogcgo/threadpprof.go b/src/runtime/testdata/testprogcgo/threadpprof.go
index e093f67e1e..ec5e750da9 100644
--- a/src/runtime/testdata/testprogcgo/threadpprof.go
+++ b/src/runtime/testdata/testprogcgo/threadpprof.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !plan9 && !windows
// +build !plan9,!windows
package main
@@ -108,7 +109,7 @@ func pprofThread() {
C.runCPUHogThread()
})
- time.Sleep(1*time.Second)
+ time.Sleep(1 * time.Second)
pprof.StopCPUProfile()
diff --git a/src/runtime/testdata/testprogcgo/threadprof.go b/src/runtime/testdata/testprogcgo/threadprof.go
index 2d4c1039fb..8081173c0f 100644
--- a/src/runtime/testdata/testprogcgo/threadprof.go
+++ b/src/runtime/testdata/testprogcgo/threadprof.go
@@ -5,8 +5,8 @@
// We only build this file with the tag "threadprof", since it starts
// a thread running a busy loop at constructor time.
-// +build !plan9,!windows
-// +build threadprof
+//go:build !plan9 && !windows && threadprof
+// +build !plan9,!windows,threadprof
package main
diff --git a/src/runtime/testdata/testprognet/signal.go b/src/runtime/testdata/testprognet/signal.go
index 4d2de79d97..dfa2e10e7a 100644
--- a/src/runtime/testdata/testprognet/signal.go
+++ b/src/runtime/testdata/testprognet/signal.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !windows && !plan9
// +build !windows,!plan9
// This is in testprognet instead of testprog because testprog
diff --git a/src/runtime/testdata/testprognet/signalexec.go b/src/runtime/testdata/testprognet/signalexec.go
index 4a988ef6c1..62ebce7176 100644
--- a/src/runtime/testdata/testprognet/signalexec.go
+++ b/src/runtime/testdata/testprognet/signalexec.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
// This is in testprognet instead of testprog because testprog
diff --git a/src/runtime/testdata/testwinlib/main.go b/src/runtime/testdata/testwinlib/main.go
index 400eaa1c82..025ef913e5 100644
--- a/src/runtime/testdata/testwinlib/main.go
+++ b/src/runtime/testdata/testwinlib/main.go
@@ -1,3 +1,4 @@
+//go:build windows && cgo
// +build windows,cgo
package main
diff --git a/src/runtime/time.go b/src/runtime/time.go
index 46e9a8c2ab..a9ad620776 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -28,8 +28,8 @@ type timer struct {
// when must be positive on an active timer.
when int64
period int64
- f func(interface{}, uintptr)
- arg interface{}
+ f func(any, uintptr)
+ arg any
seq uintptr
// What to set the when field to in timerModifiedXX status.
@@ -232,14 +232,14 @@ func resetTimer(t *timer, when int64) bool {
// modTimer modifies an existing timer.
//go:linkname modTimer time.modTimer
-func modTimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) {
+func modTimer(t *timer, when, period int64, f func(any, uintptr), arg any, seq uintptr) {
modtimer(t, when, period, f, arg, seq)
}
// Go runtime.
// Ready the goroutine arg.
-func goroutineReady(arg interface{}, seq uintptr) {
+func goroutineReady(arg any, seq uintptr) {
goready(arg.(*g), 0)
}
@@ -421,7 +421,7 @@ func dodeltimer0(pp *p) {
// modtimer modifies an existing timer.
// This is called by the netpoll code or time.Ticker.Reset or time.Timer.Reset.
// Reports whether the timer was modified before it was run.
-func modtimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) bool {
+func modtimer(t *timer, when, period int64, f func(any, uintptr), arg any, seq uintptr) bool {
if when <= 0 {
throw("timer when must be positive")
}
diff --git a/src/runtime/trace/annotation.go b/src/runtime/trace/annotation.go
index 6e18bfb755..d05b5e2261 100644
--- a/src/runtime/trace/annotation.go
+++ b/src/runtime/trace/annotation.go
@@ -98,7 +98,7 @@ func Log(ctx context.Context, category, message string) {
}
// Logf is like Log, but the value is formatted using the specified format spec.
-func Logf(ctx context.Context, category, format string, args ...interface{}) {
+func Logf(ctx context.Context, category, format string, args ...any) {
if IsEnabled() {
// Ideally this should be just Log, but that will
// add one more frame in the stack trace.