aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2025-11-11 14:48:22 -0500
committerGopher Robot <gobot@golang.org>2025-11-11 19:59:40 -0800
commit4bfc3a9d14c0b3bfcfe4ce987e47cda6720785a2 (patch)
tree0cbf1ec55d3a61af8bf45ac4a00af7e7bcc426db /src/cmd
parent2263d4aabdde8a4a466009ecc356501f87c7efb7 (diff)
downloadgo-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/cmd')
-rw-r--r--src/cmd/asm/internal/asm/endtoend_test.go6
-rw-r--r--src/cmd/asm/internal/asm/parse.go4
-rw-r--r--src/cmd/asm/internal/lex/input.go4
-rw-r--r--src/cmd/asm/main.go2
-rw-r--r--src/cmd/cgo/ast.go10
-rw-r--r--src/cmd/cgo/gcc.go8
-rw-r--r--src/cmd/cgo/godefs.go2
-rw-r--r--src/cmd/cgo/internal/testplugin/plugin_test.go2
-rw-r--r--src/cmd/cgo/main.go2
-rw-r--r--src/cmd/cgo/out.go4
-rw-r--r--src/cmd/cgo/util.go4
-rw-r--r--src/cmd/compile/internal/abt/avlint32.go46
-rw-r--r--src/cmd/compile/internal/abt/avlint32_test.go12
-rw-r--r--src/cmd/compile/internal/base/print.go18
-rw-r--r--src/cmd/compile/internal/base/timings.go2
-rw-r--r--src/cmd/compile/internal/ir/dump.go6
-rw-r--r--src/cmd/compile/internal/ir/func.go2
-rw-r--r--src/cmd/compile/internal/ir/name.go4
-rw-r--r--src/cmd/compile/internal/ir/sizeof_test.go6
-rw-r--r--src/cmd/compile/internal/logopt/log_opts.go18
-rw-r--r--src/cmd/compile/internal/loopvar/loopvar.go2
-rw-r--r--src/cmd/compile/internal/noder/writer.go4
-rw-r--r--src/cmd/compile/internal/ssa/block.go6
-rw-r--r--src/cmd/compile/internal/ssa/cache.go2
-rw-r--r--src/cmd/compile/internal/ssa/config.go6
-rw-r--r--src/cmd/compile/internal/ssa/copyelim_test.go2
-rw-r--r--src/cmd/compile/internal/ssa/debug.go2
-rw-r--r--src/cmd/compile/internal/ssa/expand_calls.go2
-rw-r--r--src/cmd/compile/internal/ssa/export_test.go10
-rw-r--r--src/cmd/compile/internal/ssa/func.go12
-rw-r--r--src/cmd/compile/internal/ssa/func_test.go2
-rw-r--r--src/cmd/compile/internal/ssa/html.go6
-rw-r--r--src/cmd/compile/internal/ssa/schedule.go4
-rw-r--r--src/cmd/compile/internal/ssa/sizeof_test.go6
-rw-r--r--src/cmd/compile/internal/ssa/value.go6
-rw-r--r--src/cmd/compile/internal/ssagen/phi.go4
-rw-r--r--src/cmd/compile/internal/ssagen/ssa.go18
-rw-r--r--src/cmd/compile/internal/syntax/branches.go2
-rw-r--r--src/cmd/compile/internal/syntax/dumper.go2
-rw-r--r--src/cmd/compile/internal/syntax/printer.go4
-rw-r--r--src/cmd/compile/internal/syntax/scanner.go4
-rw-r--r--src/cmd/compile/internal/syntax/syntax.go2
-rw-r--r--src/cmd/compile/internal/test/fixedbugs_test.go2
-rw-r--r--src/cmd/compile/internal/test/iface_test.go14
-rw-r--r--src/cmd/compile/internal/test/shift_test.go2
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go2
-rw-r--r--src/cmd/compile/internal/types/fmt.go2
-rw-r--r--src/cmd/compile/internal/types/sizeof_test.go6
-rw-r--r--src/cmd/compile/internal/types/type.go2
-rw-r--r--src/cmd/compile/internal/types2/check.go4
-rw-r--r--src/cmd/compile/internal/types2/errors.go2
-rw-r--r--src/cmd/compile/internal/types2/expr.go2
-rw-r--r--src/cmd/compile/internal/types2/hilbert_test.go2
-rw-r--r--src/cmd/compile/internal/types2/sizeof_test.go6
-rw-r--r--src/cmd/compile/internal/types2/stdlib_test.go2
-rw-r--r--src/cmd/compile/internal/types2/stmt.go4
-rw-r--r--src/cmd/compile/internal/types2/unify.go2
-rw-r--r--src/cmd/compile/internal/types2/version.go2
-rw-r--r--src/cmd/covdata/covdata.go6
-rw-r--r--src/cmd/dist/test.go4
-rw-r--r--src/cmd/dist/util.go8
-rw-r--r--src/cmd/go/internal/modload/import.go2
-rw-r--r--src/cmd/internal/cov/readcovdata.go6
-rw-r--r--src/cmd/internal/dwarf/dwarf.go19
-rw-r--r--src/cmd/internal/macho/macho.go4
-rw-r--r--src/cmd/internal/obj/dwarf.go12
-rw-r--r--src/cmd/internal/obj/link.go24
-rw-r--r--src/cmd/internal/obj/loong64/asm.go2
-rw-r--r--src/cmd/internal/obj/pcln.go12
-rw-r--r--src/cmd/internal/obj/ppc64/asm_test.go2
-rw-r--r--src/cmd/internal/obj/sizeof_test.go6
-rw-r--r--src/cmd/internal/objabi/flag.go10
-rw-r--r--src/cmd/link/internal/ld/dwarf.go14
-rw-r--r--src/cmd/link/internal/ld/link.go2
-rw-r--r--src/cmd/link/internal/ld/macho_combine_dwarf.go2
-rw-r--r--src/cmd/link/internal/ld/util.go6
-rw-r--r--src/cmd/link/internal/ld/xcoff.go3
-rw-r--r--src/cmd/link/internal/loadelf/ldelf.go2
-rw-r--r--src/cmd/link/internal/loader/loader.go4
-rw-r--r--src/cmd/link/internal/loadmacho/ldmacho.go2
-rw-r--r--src/cmd/link/internal/loadxcoff/ldxcoff.go2
-rw-r--r--src/cmd/link/internal/sym/segment.go2
82 files changed, 240 insertions, 242 deletions
diff --git a/src/cmd/asm/internal/asm/endtoend_test.go b/src/cmd/asm/internal/asm/endtoend_test.go
index 9571afc326..e53263356d 100644
--- a/src/cmd/asm/internal/asm/endtoend_test.go
+++ b/src/cmd/asm/internal/asm/endtoend_test.go
@@ -38,7 +38,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
ctxt.IsAsm = true
defer ctxt.Bso.Flush()
failed := false
- ctxt.DiagFunc = func(format string, args ...interface{}) {
+ ctxt.DiagFunc = func(format string, args ...any) {
failed = true
t.Errorf(format, args...)
}
@@ -193,7 +193,7 @@ Diff:
top := pList.Firstpc
var text *obj.LSym
ok = true
- ctxt.DiagFunc = func(format string, args ...interface{}) {
+ ctxt.DiagFunc = func(format string, args ...any) {
t.Errorf(format, args...)
ok = false
}
@@ -294,7 +294,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
failed := false
var errBuf bytes.Buffer
parser.errorWriter = &errBuf
- ctxt.DiagFunc = func(format string, args ...interface{}) {
+ ctxt.DiagFunc = func(format string, args ...any) {
failed = true
s := fmt.Sprintf(format, args...)
if !strings.HasSuffix(s, "\n") {
diff --git a/src/cmd/asm/internal/asm/parse.go b/src/cmd/asm/internal/asm/parse.go
index 545f6c7553..25d596f4d6 100644
--- a/src/cmd/asm/internal/asm/parse.go
+++ b/src/cmd/asm/internal/asm/parse.go
@@ -78,7 +78,7 @@ func NewParser(ctxt *obj.Link, ar *arch.Arch, lexer lex.TokenReader) *Parser {
// and turn it into a recoverable panic.
var panicOnError bool
-func (p *Parser) errorf(format string, args ...interface{}) {
+func (p *Parser) errorf(format string, args ...any) {
if panicOnError {
panic(fmt.Errorf(format, args...))
}
@@ -90,7 +90,7 @@ func (p *Parser) errorf(format string, args ...interface{}) {
if p.lex != nil {
// Put file and line information on head of message.
format = "%s:%d: " + format + "\n"
- args = append([]interface{}{p.lex.File(), p.lineNum}, args...)
+ args = append([]any{p.lex.File(), p.lineNum}, args...)
}
fmt.Fprintf(p.errorWriter, format, args...)
p.errorCount++
diff --git a/src/cmd/asm/internal/lex/input.go b/src/cmd/asm/internal/lex/input.go
index 789e229a77..342ac5ac48 100644
--- a/src/cmd/asm/internal/lex/input.go
+++ b/src/cmd/asm/internal/lex/input.go
@@ -68,7 +68,7 @@ func predefine(defines flags.MultiFlag) map[string]*Macro {
var panicOnError bool // For testing.
-func (in *Input) Error(args ...interface{}) {
+func (in *Input) Error(args ...any) {
if panicOnError {
panic(fmt.Errorf("%s:%d: %s", in.File(), in.Line(), fmt.Sprintln(args...)))
}
@@ -77,7 +77,7 @@ func (in *Input) Error(args ...interface{}) {
}
// expectText is like Error but adds "got XXX" where XXX is a quoted representation of the most recent token.
-func (in *Input) expectText(args ...interface{}) {
+func (in *Input) expectText(args ...any) {
in.Error(append(args, "; got", strconv.Quote(in.Stack.Text()))...)
}
diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go
index 9db1fec8be..f2697db516 100644
--- a/src/cmd/asm/main.go
+++ b/src/cmd/asm/main.go
@@ -93,7 +93,7 @@ func main() {
for _, f := range flag.Args() {
lexer := lex.NewLexer(f)
parser := asm.NewParser(ctxt, architecture, lexer)
- ctxt.DiagFunc = func(format string, args ...interface{}) {
+ ctxt.DiagFunc = func(format string, args ...any) {
diag = true
log.Printf(format, args...)
}
diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go
index 97b18cd22d..2da6ca5a30 100644
--- a/src/cmd/cgo/ast.go
+++ b/src/cmd/cgo/ast.go
@@ -199,7 +199,7 @@ func commentText(g *ast.CommentGroup) string {
return strings.Join(pieces, "")
}
-func (f *File) validateIdents(x interface{}, context astContext) {
+func (f *File) validateIdents(x any, context astContext) {
if x, ok := x.(*ast.Ident); ok {
if f.isMangledName(x.Name) {
error_(x.Pos(), "identifier %q may conflict with identifiers generated by cgo", x.Name)
@@ -208,7 +208,7 @@ func (f *File) validateIdents(x interface{}, context astContext) {
}
// Save various references we are going to need later.
-func (f *File) saveExprs(x interface{}, context astContext) {
+func (f *File) saveExprs(x any, context astContext) {
switch x := x.(type) {
case *ast.Expr:
switch (*x).(type) {
@@ -278,7 +278,7 @@ func (f *File) saveCall(call *ast.CallExpr, context astContext) {
}
// If a function should be exported add it to ExpFunc.
-func (f *File) saveExport(x interface{}, context astContext) {
+func (f *File) saveExport(x any, context astContext) {
n, ok := x.(*ast.FuncDecl)
if !ok {
return
@@ -318,7 +318,7 @@ func (f *File) saveExport(x interface{}, context astContext) {
}
// Make f.ExpFunc[i] point at the Func from this AST instead of the other one.
-func (f *File) saveExport2(x interface{}, context astContext) {
+func (f *File) saveExport2(x any, context astContext) {
n, ok := x.(*ast.FuncDecl)
if !ok {
return
@@ -355,7 +355,7 @@ const (
)
// walk walks the AST x, calling visit(f, x, context) for each node.
-func (f *File) walk(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
+func (f *File) walk(x any, context astContext, visit func(*File, any, astContext)) {
visit(f, x, context)
switch n := x.(type) {
case *ast.Expr:
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index d1b629057a..d3de3906b4 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -1158,7 +1158,7 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
// If addPosition is true, add position info to the idents of C names in arg.
func (p *Package) mangle(f *File, arg *ast.Expr, addPosition bool) (ast.Expr, bool) {
needsUnsafe := false
- f.walk(arg, ctxExpr, func(f *File, arg interface{}, context astContext) {
+ f.walk(arg, ctxExpr, func(f *File, arg any, context astContext) {
px, ok := arg.(*ast.Expr)
if !ok {
return
@@ -2439,7 +2439,7 @@ func (tr *TypeRepr) Empty() bool {
// Set modifies the type representation.
// If fargs are provided, repr is used as a format for fmt.Sprintf.
// Otherwise, repr is used unprocessed as the type representation.
-func (tr *TypeRepr) Set(repr string, fargs ...interface{}) {
+func (tr *TypeRepr) Set(repr string, fargs ...any) {
tr.Repr = repr
tr.FormatArgs = fargs
}
@@ -2713,7 +2713,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
// so execute the basic things that the struct case would do
// other than try to determine a Go representation.
tt := *t
- tt.C = &TypeRepr{"%s %s", []interface{}{dt.Kind, tag}}
+ tt.C = &TypeRepr{"%s %s", []any{dt.Kind, tag}}
// We don't know what the representation of this struct is, so don't let
// anyone allocate one on the Go side. As a side effect of this annotation,
// pointers to this type will not be considered pointers in Go. They won't
@@ -2743,7 +2743,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
t.Align = align
tt := *t
if tag != "" {
- tt.C = &TypeRepr{"struct %s", []interface{}{tag}}
+ tt.C = &TypeRepr{"struct %s", []any{tag}}
}
tt.Go = g
if c.incompleteStructs[tag] {
diff --git a/src/cmd/cgo/godefs.go b/src/cmd/cgo/godefs.go
index 9cf626c173..93f9027157 100644
--- a/src/cmd/cgo/godefs.go
+++ b/src/cmd/cgo/godefs.go
@@ -117,7 +117,7 @@ func (p *Package) godefs(f *File, args []string) string {
var gofmtBuf strings.Builder
// gofmt returns the gofmt-formatted string for an AST node.
-func gofmt(n interface{}) string {
+func gofmt(n any) string {
gofmtBuf.Reset()
err := printer.Fprint(&gofmtBuf, fset, n)
if err != nil {
diff --git a/src/cmd/cgo/internal/testplugin/plugin_test.go b/src/cmd/cgo/internal/testplugin/plugin_test.go
index 2afb542ec4..3216073edb 100644
--- a/src/cmd/cgo/internal/testplugin/plugin_test.go
+++ b/src/cmd/cgo/internal/testplugin/plugin_test.go
@@ -37,7 +37,7 @@ func TestMain(m *testing.M) {
var tmpDir string
// prettyPrintf prints lines with tmpDir sanitized.
-func prettyPrintf(format string, args ...interface{}) {
+func prettyPrintf(format string, args ...any) {
s := fmt.Sprintf(format, args...)
if tmpDir != "" {
s = strings.ReplaceAll(s, tmpDir, "$TMPDIR")
diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go
index 955d64b956..ba8e52a6e0 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -148,7 +148,7 @@ type ExpFunc struct {
// A TypeRepr contains the string representation of a type.
type TypeRepr struct {
Repr string
- FormatArgs []interface{}
+ FormatArgs []any
}
// A Type collects information about a type in both the C and Go worlds.
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index f0e07284ec..701a8530ff 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -953,7 +953,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
npad := 0
// the align is at least 1 (for char)
maxAlign := int64(1)
- argField := func(typ ast.Expr, namePat string, args ...interface{}) {
+ argField := func(typ ast.Expr, namePat string, args ...any) {
name := fmt.Sprintf(namePat, args...)
t := p.cgoType(typ)
if off%t.Align != 0 {
@@ -1412,7 +1412,7 @@ func forFieldList(fl *ast.FieldList, fn func(int, string, ast.Expr)) {
}
}
-func c(repr string, args ...interface{}) *TypeRepr {
+func c(repr string, args ...any) *TypeRepr {
return &TypeRepr{repr, args}
}
diff --git a/src/cmd/cgo/util.go b/src/cmd/cgo/util.go
index 23b4a414db..e83634ffb2 100644
--- a/src/cmd/cgo/util.go
+++ b/src/cmd/cgo/util.go
@@ -75,7 +75,7 @@ func lineno(pos token.Pos) string {
}
// Die with an error message.
-func fatalf(msg string, args ...interface{}) {
+func fatalf(msg string, args ...any) {
// If we've already printed other errors, they might have
// caused the fatal condition. Assume they're enough.
if nerrors == 0 {
@@ -86,7 +86,7 @@ func fatalf(msg string, args ...interface{}) {
var nerrors int
-func error_(pos token.Pos, msg string, args ...interface{}) {
+func error_(pos token.Pos, msg string, args ...any) {
nerrors++
if pos.IsValid() {
fmt.Fprintf(os.Stderr, "%s: ", fset.Position(pos).String())
diff --git a/src/cmd/compile/internal/abt/avlint32.go b/src/cmd/compile/internal/abt/avlint32.go
index ddfca346a2..e41a6c0ca4 100644
--- a/src/cmd/compile/internal/abt/avlint32.go
+++ b/src/cmd/compile/internal/abt/avlint32.go
@@ -28,7 +28,7 @@ type T struct {
type node32 struct {
// Standard conventions hold for left = smaller, right = larger
left, right *node32
- data interface{}
+ data any
key int32
height_ int8
}
@@ -49,21 +49,21 @@ func (t *T) IsSingle() bool {
// VisitInOrder applies f to the key and data pairs in t,
// with keys ordered from smallest to largest.
-func (t *T) VisitInOrder(f func(int32, interface{})) {
+func (t *T) VisitInOrder(f func(int32, any)) {
if t.root == nil {
return
}
t.root.visitInOrder(f)
}
-func (n *node32) nilOrData() interface{} {
+func (n *node32) nilOrData() any {
if n == nil {
return nil
}
return n.data
}
-func (n *node32) nilOrKeyAndData() (k int32, d interface{}) {
+func (n *node32) nilOrKeyAndData() (k int32, d any) {
if n == nil {
k = NOT_KEY32
d = nil
@@ -83,7 +83,7 @@ func (n *node32) height() int8 {
// Find returns the data associated with x in the tree, or
// nil if x is not in the tree.
-func (t *T) Find(x int32) interface{} {
+func (t *T) Find(x int32) any {
return t.root.find(x).nilOrData()
}
@@ -92,7 +92,7 @@ func (t *T) Find(x int32) interface{} {
// x was already a key in the tree. The previous data associated
// with x is returned, and is nil if x was not previously a
// key in the tree.
-func (t *T) Insert(x int32, data interface{}) interface{} {
+func (t *T) Insert(x int32, data any) any {
if x == NOT_KEY32 {
panic("Cannot use sentinel value -0x80000000 as key")
}
@@ -105,7 +105,7 @@ func (t *T) Insert(x int32, data interface{}) interface{} {
} else {
newroot, n, o = n.aInsert(x)
}
- var r interface{}
+ var r any
if o != nil {
r = o.data
} else {
@@ -121,7 +121,7 @@ func (t *T) Copy() *T {
return &u
}
-func (t *T) Delete(x int32) interface{} {
+func (t *T) Delete(x int32) any {
n := t.root
if n == nil {
return nil
@@ -135,7 +135,7 @@ func (t *T) Delete(x int32) interface{} {
return d.data
}
-func (t *T) DeleteMin() (int32, interface{}) {
+func (t *T) DeleteMin() (int32, any) {
n := t.root
if n == nil {
return NOT_KEY32, nil
@@ -149,7 +149,7 @@ func (t *T) DeleteMin() (int32, interface{}) {
return d.key, d.data
}
-func (t *T) DeleteMax() (int32, interface{}) {
+func (t *T) DeleteMax() (int32, any) {
n := t.root
if n == nil {
return NOT_KEY32, nil
@@ -172,7 +172,7 @@ func (t *T) Size() int {
// not be symmetric. If f returns nil, then the key and data are not
// added to the result. If f itself is nil, then whatever value was
// already present in the smaller set is used.
-func (t *T) Intersection(u *T, f func(x, y interface{}) interface{}) *T {
+func (t *T) Intersection(u *T, f func(x, y any) any) *T {
if t.Size() == 0 || u.Size() == 0 {
return &T{}
}
@@ -227,7 +227,7 @@ func (t *T) Intersection(u *T, f func(x, y interface{}) interface{}) *T {
// is given by f(t's data, u's data) -- f need not be symmetric. If f returns nil,
// then the key and data are not added to the result. If f itself is nil, then
// whatever value was already present in the larger set is used.
-func (t *T) Union(u *T, f func(x, y interface{}) interface{}) *T {
+func (t *T) Union(u *T, f func(x, y any) any) *T {
if t.Size() == 0 {
return u
}
@@ -284,7 +284,7 @@ func (t *T) Union(u *T, f func(x, y interface{}) interface{}) *T {
// of f applied to data corresponding to equal keys. If f returns nil
// (or if f is nil) then the key+data are excluded, as usual. If f
// returns not-nil, then that key+data pair is inserted. instead.
-func (t *T) Difference(u *T, f func(x, y interface{}) interface{}) *T {
+func (t *T) Difference(u *T, f func(x, y any) any) *T {
if t.Size() == 0 {
return &T{}
}
@@ -365,7 +365,7 @@ func (t *node32) equals(u *node32) bool {
return it.done() == iu.done()
}
-func (t *T) Equiv(u *T, eqv func(x, y interface{}) bool) bool {
+func (t *T) Equiv(u *T, eqv func(x, y any) bool) bool {
if t == u {
return true
}
@@ -375,7 +375,7 @@ func (t *T) Equiv(u *T, eqv func(x, y interface{}) bool) bool {
return t.root.equiv(u.root, eqv)
}
-func (t *node32) equiv(u *node32, eqv func(x, y interface{}) bool) bool {
+func (t *node32) equiv(u *node32, eqv func(x, y any) bool) bool {
if t == u {
return true
}
@@ -404,7 +404,7 @@ type Iterator struct {
it iterator
}
-func (it *Iterator) Next() (int32, interface{}) {
+func (it *Iterator) Next() (int32, any) {
x := it.it.next()
if x == nil {
return NOT_KEY32, nil
@@ -461,37 +461,37 @@ func (it *iterator) next() *node32 {
// Min returns the minimum element of t.
// If t is empty, then (NOT_KEY32, nil) is returned.
-func (t *T) Min() (k int32, d interface{}) {
+func (t *T) Min() (k int32, d any) {
return t.root.min().nilOrKeyAndData()
}
// Max returns the maximum element of t.
// If t is empty, then (NOT_KEY32, nil) is returned.
-func (t *T) Max() (k int32, d interface{}) {
+func (t *T) Max() (k int32, d any) {
return t.root.max().nilOrKeyAndData()
}
// Glb returns the greatest-lower-bound-exclusive of x and the associated
// data. If x has no glb in the tree, then (NOT_KEY32, nil) is returned.
-func (t *T) Glb(x int32) (k int32, d interface{}) {
+func (t *T) Glb(x int32) (k int32, d any) {
return t.root.glb(x, false).nilOrKeyAndData()
}
// GlbEq returns the greatest-lower-bound-inclusive of x and the associated
// data. If x has no glbEQ in the tree, then (NOT_KEY32, nil) is returned.
-func (t *T) GlbEq(x int32) (k int32, d interface{}) {
+func (t *T) GlbEq(x int32) (k int32, d any) {
return t.root.glb(x, true).nilOrKeyAndData()
}
// Lub returns the least-upper-bound-exclusive of x and the associated
// data. If x has no lub in the tree, then (NOT_KEY32, nil) is returned.
-func (t *T) Lub(x int32) (k int32, d interface{}) {
+func (t *T) Lub(x int32) (k int32, d any) {
return t.root.lub(x, false).nilOrKeyAndData()
}
// LubEq returns the least-upper-bound-inclusive of x and the associated
// data. If x has no lubEq in the tree, then (NOT_KEY32, nil) is returned.
-func (t *T) LubEq(x int32) (k int32, d interface{}) {
+func (t *T) LubEq(x int32) (k int32, d any) {
return t.root.lub(x, true).nilOrKeyAndData()
}
@@ -499,7 +499,7 @@ func (t *node32) isLeaf() bool {
return t.left == nil && t.right == nil && t.height_ == LEAF_HEIGHT
}
-func (t *node32) visitInOrder(f func(int32, interface{})) {
+func (t *node32) visitInOrder(f func(int32, any)) {
if t.left != nil {
t.left.visitInOrder(f)
}
diff --git a/src/cmd/compile/internal/abt/avlint32_test.go b/src/cmd/compile/internal/abt/avlint32_test.go
index 7fa9ed4fd6..71962445f2 100644
--- a/src/cmd/compile/internal/abt/avlint32_test.go
+++ b/src/cmd/compile/internal/abt/avlint32_test.go
@@ -317,7 +317,7 @@ func applicIterator(te *testing.T, x []int32) {
}
}
-func equiv(a, b interface{}) bool {
+func equiv(a, b any) bool {
sa, sb := a.(*sstring), b.(*sstring)
return *sa == *sb
}
@@ -450,16 +450,16 @@ func TestEquals(t *testing.T) {
[]int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2})
}
-func first(x, y interface{}) interface{} {
+func first(x, y any) any {
return x
}
-func second(x, y interface{}) interface{} {
+func second(x, y any) any {
return y
}
-func alwaysNil(x, y interface{}) interface{} {
+func alwaysNil(x, y any) any {
return nil
}
-func smaller(x, y interface{}) interface{} {
+func smaller(x, y any) any {
xi, _ := strconv.Atoi(fmt.Sprint(x))
yi, _ := strconv.Atoi(fmt.Sprint(y))
if xi < yi {
@@ -560,7 +560,7 @@ func (s *sstring) String() string {
return s.s
}
-func stringer(s string) interface{} {
+func stringer(s string) any {
return &sstring{s}
}
diff --git a/src/cmd/compile/internal/base/print.go b/src/cmd/compile/internal/base/print.go
index 9e3348c1ec..6bfc84cd62 100644
--- a/src/cmd/compile/internal/base/print.go
+++ b/src/cmd/compile/internal/base/print.go
@@ -45,7 +45,7 @@ func SyntaxErrors() int {
}
// addErrorMsg adds a new errorMsg (which may be a warning) to errorMsgs.
-func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...interface{}) {
+func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...any) {
msg := fmt.Sprintf(format, args...)
// Only add the position if know the position.
// See issue golang.org/issue/11361.
@@ -108,12 +108,12 @@ func sameline(a, b src.XPos) bool {
}
// Errorf reports a formatted error at the current line.
-func Errorf(format string, args ...interface{}) {
+func Errorf(format string, args ...any) {
ErrorfAt(Pos, 0, format, args...)
}
// ErrorfAt reports a formatted error message at pos.
-func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...interface{}) {
+func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...any) {
msg := fmt.Sprintf(format, args...)
if strings.HasPrefix(msg, "syntax error") {
@@ -164,7 +164,7 @@ func UpdateErrorDot(line string, name, expr string) {
// In general the Go compiler does NOT generate warnings,
// so this should be used only when the user has opted in
// to additional output by setting a particular flag.
-func Warn(format string, args ...interface{}) {
+func Warn(format string, args ...any) {
WarnfAt(Pos, format, args...)
}
@@ -172,7 +172,7 @@ func Warn(format string, args ...interface{}) {
// In general the Go compiler does NOT generate warnings,
// so this should be used only when the user has opted in
// to additional output by setting a particular flag.
-func WarnfAt(pos src.XPos, format string, args ...interface{}) {
+func WarnfAt(pos src.XPos, format string, args ...any) {
addErrorMsg(pos, 0, format, args...)
if Flag.LowerM != 0 {
FlushErrors()
@@ -191,7 +191,7 @@ func WarnfAt(pos src.XPos, format string, args ...interface{}) {
// prints a stack trace.
//
// If -h has been specified, Fatalf panics to force the usual runtime info dump.
-func Fatalf(format string, args ...interface{}) {
+func Fatalf(format string, args ...any) {
FatalfAt(Pos, format, args...)
}
@@ -209,7 +209,7 @@ var bugStack = counter.NewStack("compile/bug", 16) // 16 is arbitrary; used by g
// prints a stack trace.
//
// If -h has been specified, FatalfAt panics to force the usual runtime info dump.
-func FatalfAt(pos src.XPos, format string, args ...interface{}) {
+func FatalfAt(pos src.XPos, format string, args ...any) {
FlushErrors()
bugStack.Inc()
@@ -244,14 +244,14 @@ func Assert(b bool) {
}
// Assertf reports a fatal error with Fatalf, unless b is true.
-func Assertf(b bool, format string, args ...interface{}) {
+func Assertf(b bool, format string, args ...any) {
if !b {
Fatalf(format, args...)
}
}
// AssertfAt reports a fatal error with FatalfAt, unless b is true.
-func AssertfAt(b bool, pos src.XPos, format string, args ...interface{}) {
+func AssertfAt(b bool, pos src.XPos, format string, args ...any) {
if !b {
FatalfAt(pos, format, args...)
}
diff --git a/src/cmd/compile/internal/base/timings.go b/src/cmd/compile/internal/base/timings.go
index f48ac93699..cbcd4dc6f5 100644
--- a/src/cmd/compile/internal/base/timings.go
+++ b/src/cmd/compile/internal/base/timings.go
@@ -168,7 +168,7 @@ type lines [][]string
func (lines *lines) add(label string, n int, dt, tot time.Duration, events []*event) {
var line []string
- add := func(format string, args ...interface{}) {
+ add := func(format string, args ...any) {
line = append(line, fmt.Sprintf(format, args...))
}
diff --git a/src/cmd/compile/internal/ir/dump.go b/src/cmd/compile/internal/ir/dump.go
index 4c218682ea..3e5e6fbdce 100644
--- a/src/cmd/compile/internal/ir/dump.go
+++ b/src/cmd/compile/internal/ir/dump.go
@@ -21,7 +21,7 @@ import (
)
// DumpAny is like FDumpAny but prints to stderr.
-func DumpAny(root interface{}, filter string, depth int) {
+func DumpAny(root any, filter string, depth int) {
FDumpAny(os.Stderr, root, filter, depth)
}
@@ -42,7 +42,7 @@ func DumpAny(root interface{}, filter string, depth int) {
// rather than their type; struct fields with zero values or
// non-matching field names are omitted, and "…" means recursion
// depth has been reached or struct fields have been omitted.
-func FDumpAny(w io.Writer, root interface{}, filter string, depth int) {
+func FDumpAny(w io.Writer, root any, filter string, depth int) {
if root == nil {
fmt.Fprintln(w, "nil")
return
@@ -110,7 +110,7 @@ func (p *dumper) Write(data []byte) (n int, err error) {
}
// printf is a convenience wrapper.
-func (p *dumper) printf(format string, args ...interface{}) {
+func (p *dumper) printf(format string, args ...any) {
if _, err := fmt.Fprintf(p, format, args...); err != nil {
panic(err)
}
diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go
index 668537c90e..e027fe8290 100644
--- a/src/cmd/compile/internal/ir/func.go
+++ b/src/cmd/compile/internal/ir/func.go
@@ -90,7 +90,7 @@ type Func struct {
Marks []Mark
FieldTrack map[*obj.LSym]struct{}
- DebugInfo interface{}
+ DebugInfo any
LSym *obj.LSym // Linker object in this function's native ABI (Func.ABI)
Inl *Inline
diff --git a/src/cmd/compile/internal/ir/name.go b/src/cmd/compile/internal/ir/name.go
index 6f8d0a7fcc..01f1c0c502 100644
--- a/src/cmd/compile/internal/ir/name.go
+++ b/src/cmd/compile/internal/ir/name.go
@@ -43,8 +43,8 @@ type Name struct {
Func *Func // TODO(austin): nil for I.M
Offset_ int64
val constant.Value
- Opt interface{} // for use by escape analysis
- Embed *[]Embed // list of embedded files, for ONAME var
+ Opt any // for use by escape analysis
+ Embed *[]Embed // list of embedded files, for ONAME var
// For a local variable (not param) or extern, the initializing assignment (OAS or OAS2).
// For a closure var, the ONAME node of the original (outermost) captured variable.
diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go
index 14b6b4f3cd..b805155e6e 100644
--- a/src/cmd/compile/internal/ir/sizeof_test.go
+++ b/src/cmd/compile/internal/ir/sizeof_test.go
@@ -16,9 +16,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
}{
{Func{}, 184, 312},
{Name{}, 96, 160},
diff --git a/src/cmd/compile/internal/logopt/log_opts.go b/src/cmd/compile/internal/logopt/log_opts.go
index d08f6fb5d6..c47c9ee5af 100644
--- a/src/cmd/compile/internal/logopt/log_opts.go
+++ b/src/cmd/compile/internal/logopt/log_opts.go
@@ -224,12 +224,12 @@ type Diagnostic struct {
// A LoggedOpt is what the compiler produces and accumulates,
// to be converted to JSON for human or IDE consumption.
type LoggedOpt struct {
- pos src.XPos // Source code position at which the event occurred. If it is inlined, outer and all inlined locations will appear in JSON.
- lastPos src.XPos // Usually the same as pos; current exception is for reporting entire range of transformed loops
- compilerPass string // Compiler pass. For human/adhoc consumption; does not appear in JSON (yet)
- functionName string // Function name. For human/adhoc consumption; does not appear in JSON (yet)
- what string // The (non) optimization; "nilcheck", "boundsCheck", "inline", "noInline"
- target []interface{} // Optional target(s) or parameter(s) of "what" -- what was inlined, why it was not, size of copy, etc. 1st is most important/relevant.
+ pos src.XPos // Source code position at which the event occurred. If it is inlined, outer and all inlined locations will appear in JSON.
+ lastPos src.XPos // Usually the same as pos; current exception is for reporting entire range of transformed loops
+ compilerPass string // Compiler pass. For human/adhoc consumption; does not appear in JSON (yet)
+ functionName string // Function name. For human/adhoc consumption; does not appear in JSON (yet)
+ what string // The (non) optimization; "nilcheck", "boundsCheck", "inline", "noInline"
+ target []any // Optional target(s) or parameter(s) of "what" -- what was inlined, why it was not, size of copy, etc. 1st is most important/relevant.
}
type logFormat uint8
@@ -325,7 +325,7 @@ var mu = sync.Mutex{} // mu protects loggedOpts.
// Pos is the source position (including inlining), what is the message, pass is which pass created the message,
// funcName is the name of the function
// A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape?
-func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) *LoggedOpt {
+func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...any) *LoggedOpt {
pass = strings.ReplaceAll(pass, " ", "_")
return &LoggedOpt{pos, lastPos, pass, funcName, what, args}
}
@@ -333,7 +333,7 @@ func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...in
// LogOpt logs information about a (usually missed) optimization performed by the compiler.
// Pos is the source position (including inlining), what is the message, pass is which pass created the message,
// funcName is the name of the function.
-func LogOpt(pos src.XPos, what, pass, funcName string, args ...interface{}) {
+func LogOpt(pos src.XPos, what, pass, funcName string, args ...any) {
if Format == None {
return
}
@@ -346,7 +346,7 @@ func LogOpt(pos src.XPos, what, pass, funcName string, args ...interface{}) {
// LogOptRange is the same as LogOpt, but includes the ability to express a range of positions,
// not just a point.
-func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) {
+func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...any) {
if Format == None {
return
}
diff --git a/src/cmd/compile/internal/loopvar/loopvar.go b/src/cmd/compile/internal/loopvar/loopvar.go
index 5a4590d299..267df2f905 100644
--- a/src/cmd/compile/internal/loopvar/loopvar.go
+++ b/src/cmd/compile/internal/loopvar/loopvar.go
@@ -557,7 +557,7 @@ func LogTransformations(transformed []VarAndLoop) {
if logopt.Enabled() {
// For automated checking of coverage of this transformation, include this in the JSON information.
- var nString interface{} = n
+ var nString any = n
if inner != outer {
nString = fmt.Sprintf("%v (from inline)", n)
}
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index 9c90d221c2..0b5aa007bf 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -120,12 +120,12 @@ func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo ma
}
// errorf reports a user error about thing p.
-func (pw *pkgWriter) errorf(p poser, msg string, args ...interface{}) {
+func (pw *pkgWriter) errorf(p poser, msg string, args ...any) {
base.ErrorfAt(pw.m.pos(p), 0, msg, args...)
}
// fatalf reports an internal compiler error about thing p.
-func (pw *pkgWriter) fatalf(p poser, msg string, args ...interface{}) {
+func (pw *pkgWriter) fatalf(p poser, msg string, args ...any) {
base.FatalfAt(pw.m.pos(p), msg, args...)
}
diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go
index 1240bfd655..278a6b0d1d 100644
--- a/src/cmd/compile/internal/ssa/block.go
+++ b/src/cmd/compile/internal/ssa/block.go
@@ -424,9 +424,9 @@ func (b *Block) likelyBranch() bool {
return true
}
-func (b *Block) Logf(msg string, args ...interface{}) { b.Func.Logf(msg, args...) }
-func (b *Block) Log() bool { return b.Func.Log() }
-func (b *Block) Fatalf(msg string, args ...interface{}) { b.Func.Fatalf(msg, args...) }
+func (b *Block) Logf(msg string, args ...any) { b.Func.Logf(msg, args...) }
+func (b *Block) Log() bool { return b.Func.Log() }
+func (b *Block) Fatalf(msg string, args ...any) { b.Func.Fatalf(msg, args...) }
type BranchPrediction int8
diff --git a/src/cmd/compile/internal/ssa/cache.go b/src/cmd/compile/internal/ssa/cache.go
index 0c16efcd57..59d768c34f 100644
--- a/src/cmd/compile/internal/ssa/cache.go
+++ b/src/cmd/compile/internal/ssa/cache.go
@@ -29,7 +29,7 @@ type Cache struct {
ValueToProgAfter []*obj.Prog
debugState debugState
- Liveness interface{} // *gc.livenessFuncCache
+ Liveness any // *gc.livenessFuncCache
// Free "headers" for use by the allocators in allocators.go.
// Used to put slices in sync.Pools without allocation.
diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go
index ec0240941c..3540db498c 100644
--- a/src/cmd/compile/internal/ssa/config.go
+++ b/src/cmd/compile/internal/ssa/config.go
@@ -126,17 +126,17 @@ func (t *Types) SetTypPtrs() {
type Logger interface {
// Logf logs a message from the compiler.
- Logf(string, ...interface{})
+ Logf(string, ...any)
// Log reports whether logging is not a no-op
// some logging calls account for more than a few heap allocations.
Log() bool
// Fatalf reports a compiler error and exits.
- Fatalf(pos src.XPos, msg string, args ...interface{})
+ Fatalf(pos src.XPos, msg string, args ...any)
// Warnl writes compiler messages in the form expected by "errorcheck" tests
- Warnl(pos src.XPos, fmt_ string, args ...interface{})
+ Warnl(pos src.XPos, fmt_ string, args ...any)
// Forwards the Debug flags from gc
Debug_checknil() bool
diff --git a/src/cmd/compile/internal/ssa/copyelim_test.go b/src/cmd/compile/internal/ssa/copyelim_test.go
index fe31b12191..20e548f7fc 100644
--- a/src/cmd/compile/internal/ssa/copyelim_test.go
+++ b/src/cmd/compile/internal/ssa/copyelim_test.go
@@ -20,7 +20,7 @@ func BenchmarkCopyElim100000(b *testing.B) { benchmarkCopyElim(b, 100000) }
func benchmarkCopyElim(b *testing.B, n int) {
c := testConfig(b)
- values := make([]interface{}, 0, n+2)
+ values := make([]any, 0, n+2)
values = append(values, Valu("mem", OpInitMem, types.TypeMem, 0, nil))
last := "mem"
for i := 0; i < n; i++ {
diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go
index 7edc414bda..687abc42cc 100644
--- a/src/cmd/compile/internal/ssa/debug.go
+++ b/src/cmd/compile/internal/ssa/debug.go
@@ -195,7 +195,7 @@ type RegisterSet uint64
// logf prints debug-specific logging to stdout (always stdout) if the
// current function is tagged by GOSSAFUNC (for ssa output directed
// either to stdout or html).
-func (s *debugState) logf(msg string, args ...interface{}) {
+func (s *debugState) logf(msg string, args ...any) {
if s.f.PrintOrHtmlSSA {
fmt.Printf(msg, args...)
}
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go
index 1e2a0df072..8a5b364c2f 100644
--- a/src/cmd/compile/internal/ssa/expand_calls.go
+++ b/src/cmd/compile/internal/ssa/expand_calls.go
@@ -951,7 +951,7 @@ func (x *expandState) indent(n int) {
}
// Printf does an indented fmt.Printf on the format and args.
-func (x *expandState) Printf(format string, a ...interface{}) (n int, err error) {
+func (x *expandState) Printf(format string, a ...any) (n int, err error) {
if x.indentLevel > 0 {
fmt.Printf("%[1]*s", x.indentLevel, "")
}
diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go
index c33c77f891..3ab0be7311 100644
--- a/src/cmd/compile/internal/ssa/export_test.go
+++ b/src/cmd/compile/internal/ssa/export_test.go
@@ -98,12 +98,12 @@ func (TestFrontend) UseWriteBarrier() bool {
return true // only writebarrier_test cares
}
-func (d TestFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
-func (d TestFrontend) Log() bool { return true }
+func (d TestFrontend) Logf(msg string, args ...any) { d.t.Logf(msg, args...) }
+func (d TestFrontend) Log() bool { return true }
-func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
-func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
-func (d TestFrontend) Debug_checknil() bool { return false }
+func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...any) { d.t.Fatalf(msg, args...) }
+func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...any) { d.t.Logf(msg, args...) }
+func (d TestFrontend) Debug_checknil() bool { return false }
func (d TestFrontend) Func() *ir.Func {
return d.f
diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go
index fc8cb3f2fe..56690c8284 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -336,7 +336,7 @@ func (f *Func) newValueNoBlock(op Op, t *types.Type, pos src.XPos) *Value {
// context to allow item-by-item comparisons across runs.
// For example:
// awk 'BEGIN {FS="\t"} $3~/TIME/{sum+=$4} END{print "t(ns)=",sum}' t.log
-func (f *Func) LogStat(key string, args ...interface{}) {
+func (f *Func) LogStat(key string, args ...any) {
value := ""
for _, a := range args {
value += fmt.Sprintf("\t%v", a)
@@ -729,12 +729,12 @@ func (f *Func) ConstOffPtrSP(t *types.Type, c int64, sp *Value) *Value {
return v
}
-func (f *Func) Frontend() Frontend { return f.fe }
-func (f *Func) Warnl(pos src.XPos, msg string, args ...interface{}) { f.fe.Warnl(pos, msg, args...) }
-func (f *Func) Logf(msg string, args ...interface{}) { f.fe.Logf(msg, args...) }
-func (f *Func) Log() bool { return f.fe.Log() }
+func (f *Func) Frontend() Frontend { return f.fe }
+func (f *Func) Warnl(pos src.XPos, msg string, args ...any) { f.fe.Warnl(pos, msg, args...) }
+func (f *Func) Logf(msg string, args ...any) { f.fe.Logf(msg, args...) }
+func (f *Func) Log() bool { return f.fe.Log() }
-func (f *Func) Fatalf(msg string, args ...interface{}) {
+func (f *Func) Fatalf(msg string, args ...any) {
stats := "crashed"
if f.Log() {
f.Logf(" pass %s end %s\n", f.pass.name, stats)
diff --git a/src/cmd/compile/internal/ssa/func_test.go b/src/cmd/compile/internal/ssa/func_test.go
index 4639d674e1..1a378d4a95 100644
--- a/src/cmd/compile/internal/ssa/func_test.go
+++ b/src/cmd/compile/internal/ssa/func_test.go
@@ -206,7 +206,7 @@ func (c *Conf) Fun(entry string, blocs ...bloc) fun {
// Bloc defines a block for Fun. The bloc name should be unique
// across the containing Fun. entries should consist of calls to valu,
// as well as one call to Goto, If, or Exit to specify the block kind.
-func Bloc(name string, entries ...interface{}) bloc {
+func Bloc(name string, entries ...any) bloc {
b := bloc{}
b.name = name
seenCtrl := false
diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go
index 85a414f31e..7a6683e9f0 100644
--- a/src/cmd/compile/internal/ssa/html.go
+++ b/src/cmd/compile/internal/ssa/html.go
@@ -53,13 +53,13 @@ func NewHTMLWriter(path string, f *Func, cfgMask string) *HTMLWriter {
}
// Fatalf reports an error and exits.
-func (w *HTMLWriter) Fatalf(msg string, args ...interface{}) {
+func (w *HTMLWriter) Fatalf(msg string, args ...any) {
fe := w.Func.Frontend()
fe.Fatalf(src.NoXPos, msg, args...)
}
// Logf calls the (w *HTMLWriter).Func's Logf method passing along a msg and args.
-func (w *HTMLWriter) Logf(msg string, args ...interface{}) {
+func (w *HTMLWriter) Logf(msg string, args ...any) {
w.Func.Logf(msg, args...)
}
@@ -945,7 +945,7 @@ func (w *HTMLWriter) WriteMultiTitleColumn(phase string, titles []string, class,
w.WriteString("</td>\n")
}
-func (w *HTMLWriter) Printf(msg string, v ...interface{}) {
+func (w *HTMLWriter) Printf(msg string, v ...any) {
if _, err := fmt.Fprintf(w.w, msg, v...); err != nil {
w.Fatalf("%v", err)
}
diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go
index 325118a182..8006253145 100644
--- a/src/cmd/compile/internal/ssa/schedule.go
+++ b/src/cmd/compile/internal/ssa/schedule.go
@@ -36,13 +36,13 @@ type ValHeap struct {
func (h ValHeap) Len() int { return len(h.a) }
func (h ValHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] }
-func (h *ValHeap) Push(x interface{}) {
+func (h *ValHeap) Push(x any) {
// Push and Pop use pointer receivers because they modify the slice's length,
// not just its contents.
v := x.(*Value)
h.a = append(h.a, v)
}
-func (h *ValHeap) Pop() interface{} {
+func (h *ValHeap) Pop() any {
old := h.a
n := len(old)
x := old[n-1]
diff --git a/src/cmd/compile/internal/ssa/sizeof_test.go b/src/cmd/compile/internal/ssa/sizeof_test.go
index a27002ee3a..766598ebd5 100644
--- a/src/cmd/compile/internal/ssa/sizeof_test.go
+++ b/src/cmd/compile/internal/ssa/sizeof_test.go
@@ -16,9 +16,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
}{
{Value{}, 72, 112},
{Block{}, 164, 304},
diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go
index 51a70c7fd4..809ed6c85a 100644
--- a/src/cmd/compile/internal/ssa/value.go
+++ b/src/cmd/compile/internal/ssa/value.go
@@ -471,9 +471,9 @@ func (v *Value) copyIntoWithXPos(b *Block, pos src.XPos) *Value {
return c
}
-func (v *Value) Logf(msg string, args ...interface{}) { v.Block.Logf(msg, args...) }
-func (v *Value) Log() bool { return v.Block.Log() }
-func (v *Value) Fatalf(msg string, args ...interface{}) {
+func (v *Value) Logf(msg string, args ...any) { v.Block.Logf(msg, args...) }
+func (v *Value) Log() bool { return v.Block.Log() }
+func (v *Value) Fatalf(msg string, args ...any) {
v.Block.Func.fe.Fatalf(v.Pos, msg, args...)
}
diff --git a/src/cmd/compile/internal/ssagen/phi.go b/src/cmd/compile/internal/ssagen/phi.go
index 0dcf353bf4..4043ac4576 100644
--- a/src/cmd/compile/internal/ssagen/phi.go
+++ b/src/cmd/compile/internal/ssagen/phi.go
@@ -396,11 +396,11 @@ type blockHeap struct {
func (h *blockHeap) Len() int { return len(h.a) }
func (h *blockHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] }
-func (h *blockHeap) Push(x interface{}) {
+func (h *blockHeap) Push(x any) {
v := x.(*ssa.Block)
h.a = append(h.a, v)
}
-func (h *blockHeap) Pop() interface{} {
+func (h *blockHeap) Pop() any {
old := h.a
n := len(old)
x := old[n-1]
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index ae7d57566f..3dea733bbd 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -1115,13 +1115,13 @@ func (s *state) label(sym *types.Sym) *ssaLabel {
return lab
}
-func (s *state) Logf(msg string, args ...interface{}) { s.f.Logf(msg, args...) }
-func (s *state) Log() bool { return s.f.Log() }
-func (s *state) Fatalf(msg string, args ...interface{}) {
+func (s *state) Logf(msg string, args ...any) { s.f.Logf(msg, args...) }
+func (s *state) Log() bool { return s.f.Log() }
+func (s *state) Fatalf(msg string, args ...any) {
s.f.Frontend().Fatalf(s.peekPos(), msg, args...)
}
-func (s *state) Warnl(pos src.XPos, msg string, args ...interface{}) { s.f.Warnl(pos, msg, args...) }
-func (s *state) Debug_checknil() bool { return s.f.Frontend().Debug_checknil() }
+func (s *state) Warnl(pos src.XPos, msg string, args ...any) { s.f.Warnl(pos, msg, args...) }
+func (s *state) Debug_checknil() bool { return s.f.Frontend().Debug_checknil() }
func ssaMarker(name string) *ir.Name {
return ir.NewNameAt(base.Pos, &types.Sym{Name: name}, nil)
@@ -7714,7 +7714,7 @@ func (e *ssafn) SplitSlot(parent *ssa.LocalSlot, suffix string, offset int64, t
}
// Logf logs a message from the compiler.
-func (e *ssafn) Logf(msg string, args ...interface{}) {
+func (e *ssafn) Logf(msg string, args ...any) {
if e.log {
fmt.Printf(msg, args...)
}
@@ -7725,15 +7725,15 @@ func (e *ssafn) Log() bool {
}
// Fatalf reports a compiler error and exits.
-func (e *ssafn) Fatalf(pos src.XPos, msg string, args ...interface{}) {
+func (e *ssafn) Fatalf(pos src.XPos, msg string, args ...any) {
base.Pos = pos
- nargs := append([]interface{}{ir.FuncName(e.curfn)}, args...)
+ nargs := append([]any{ir.FuncName(e.curfn)}, args...)
base.Fatalf("'%s': "+msg, nargs...)
}
// Warnl reports a "warning", which is usually flag-triggered
// logging output for the benefit of tests.
-func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...interface{}) {
+func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...any) {
base.WarnfAt(pos, fmt_, args...)
}
diff --git a/src/cmd/compile/internal/syntax/branches.go b/src/cmd/compile/internal/syntax/branches.go
index 8b360176e8..3a2479bb8a 100644
--- a/src/cmd/compile/internal/syntax/branches.go
+++ b/src/cmd/compile/internal/syntax/branches.go
@@ -61,7 +61,7 @@ type block struct {
lstmt *LabeledStmt // labeled statement associated with this block, or nil
}
-func (ls *labelScope) errf(pos Pos, format string, args ...interface{}) {
+func (ls *labelScope) errf(pos Pos, format string, args ...any) {
ls.errh(Error{pos, fmt.Sprintf(format, args...)})
}
diff --git a/src/cmd/compile/internal/syntax/dumper.go b/src/cmd/compile/internal/syntax/dumper.go
index d5247886da..9a021a4582 100644
--- a/src/cmd/compile/internal/syntax/dumper.go
+++ b/src/cmd/compile/internal/syntax/dumper.go
@@ -89,7 +89,7 @@ type writeError struct {
}
// printf is a convenience wrapper that takes care of print errors.
-func (p *dumper) printf(format string, args ...interface{}) {
+func (p *dumper) printf(format string, args ...any) {
if _, err := fmt.Fprintf(p, format, args...); err != nil {
panic(writeError{err})
}
diff --git a/src/cmd/compile/internal/syntax/printer.go b/src/cmd/compile/internal/syntax/printer.go
index d86d77e73f..86d93e8932 100644
--- a/src/cmd/compile/internal/syntax/printer.go
+++ b/src/cmd/compile/internal/syntax/printer.go
@@ -247,7 +247,7 @@ func mayCombine(prev token, next byte) (b bool) {
// return
}
-func (p *printer) print(args ...interface{}) {
+func (p *printer) print(args ...any) {
for i := 0; i < len(args); i++ {
switch x := args[i].(type) {
case nil:
@@ -455,7 +455,7 @@ func (p *printer) printRawNode(n Node) {
p.printExprList(n.ElemList)
case *ArrayType:
- var len interface{} = _DotDotDot
+ var len any = _DotDotDot
if n.Len != nil {
len = n.Len
}
diff --git a/src/cmd/compile/internal/syntax/scanner.go b/src/cmd/compile/internal/syntax/scanner.go
index 807d838386..700908f6bd 100644
--- a/src/cmd/compile/internal/syntax/scanner.go
+++ b/src/cmd/compile/internal/syntax/scanner.go
@@ -50,12 +50,12 @@ func (s *scanner) init(src io.Reader, errh func(line, col uint, msg string), mod
}
// errorf reports an error at the most recently read character position.
-func (s *scanner) errorf(format string, args ...interface{}) {
+func (s *scanner) errorf(format string, args ...any) {
s.error(fmt.Sprintf(format, args...))
}
// errorAtf reports an error at a byte column offset relative to the current token start.
-func (s *scanner) errorAtf(offset int, format string, args ...interface{}) {
+func (s *scanner) errorAtf(offset int, format string, args ...any) {
s.errh(s.line, s.col+uint(offset), fmt.Sprintf(format, args...))
}
diff --git a/src/cmd/compile/internal/syntax/syntax.go b/src/cmd/compile/internal/syntax/syntax.go
index 83b102da9f..dd8f2b8200 100644
--- a/src/cmd/compile/internal/syntax/syntax.go
+++ b/src/cmd/compile/internal/syntax/syntax.go
@@ -36,7 +36,7 @@ type ErrorHandler func(err error)
// A Pragma value augments a package, import, const, func, type, or var declaration.
// Its meaning is entirely up to the PragmaHandler,
// except that nil is used to mean “no pragma seen.”
-type Pragma interface{}
+type Pragma any
// A PragmaHandler is used to process //go: directives while scanning.
// It is passed the current pragma value, which starts out being nil,
diff --git a/src/cmd/compile/internal/test/fixedbugs_test.go b/src/cmd/compile/internal/test/fixedbugs_test.go
index 8ff7a60aae..b6d3e248ad 100644
--- a/src/cmd/compile/internal/test/fixedbugs_test.go
+++ b/src/cmd/compile/internal/test/fixedbugs_test.go
@@ -24,7 +24,7 @@ func makeT() T {
var g T
-var sink interface{}
+var sink any
func TestIssue15854(t *testing.T) {
for i := 0; i < 10000; i++ {
diff --git a/src/cmd/compile/internal/test/iface_test.go b/src/cmd/compile/internal/test/iface_test.go
index db41eb8e55..cb7dc70c2f 100644
--- a/src/cmd/compile/internal/test/iface_test.go
+++ b/src/cmd/compile/internal/test/iface_test.go
@@ -13,7 +13,7 @@ var x int
func TestEfaceConv1(t *testing.T) {
a := 5
- i := interface{}(a)
+ i := any(a)
a += 2
if got := i.(int); got != 5 {
t.Errorf("wanted 5, got %d\n", got)
@@ -23,7 +23,7 @@ func TestEfaceConv1(t *testing.T) {
func TestEfaceConv2(t *testing.T) {
a := 5
sink = &a
- i := interface{}(a)
+ i := any(a)
a += 2
if got := i.(int); got != 5 {
t.Errorf("wanted 5, got %d\n", got)
@@ -38,7 +38,7 @@ func TestEfaceConv3(t *testing.T) {
}
//go:noinline
-func e2int3(i interface{}) int {
+func e2int3(i any) int {
x = 7
return i.(int)
}
@@ -51,7 +51,7 @@ func TestEfaceConv4(t *testing.T) {
}
//go:noinline
-func e2int4(i interface{}, p *int) int {
+func e2int4(i any, p *int) int {
*p = 7
return i.(int)
}
@@ -69,7 +69,7 @@ func (i Int) foo() {
func TestIfaceConv1(t *testing.T) {
a := Int(5)
- i := interface{}(a)
+ i := any(a)
a += 2
if got := i.(Int); got != 5 {
t.Errorf("wanted 5, got %d\n", int(got))
@@ -79,7 +79,7 @@ func TestIfaceConv1(t *testing.T) {
func TestIfaceConv2(t *testing.T) {
a := Int(5)
sink = &a
- i := interface{}(a)
+ i := any(a)
a += 2
if got := i.(Int); got != 5 {
t.Errorf("wanted 5, got %d\n", int(got))
@@ -121,7 +121,7 @@ func BenchmarkEfaceInteger(b *testing.B) {
}
//go:noinline
-func i2int(i interface{}) int {
+func i2int(i any) int {
return i.(int)
}
diff --git a/src/cmd/compile/internal/test/shift_test.go b/src/cmd/compile/internal/test/shift_test.go
index 492379e188..d540f25c73 100644
--- a/src/cmd/compile/internal/test/shift_test.go
+++ b/src/cmd/compile/internal/test/shift_test.go
@@ -916,7 +916,7 @@ func TestShiftGeneric(t *testing.T) {
signed bool
shiftWidth int
left bool
- f interface{}
+ f any
}{
{64, true, 64, true, func(n int64, s uint64) int64 { return n << s }},
{64, true, 64, false, func(n int64, s uint64) int64 { return n >> s }},
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index c97220e6c2..d7aad9c6b9 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -713,7 +713,7 @@ func implicitstar(n ir.Node) ir.Node {
return Expr(star)
}
-func needOneArg(n *ir.CallExpr, f string, args ...interface{}) (ir.Node, bool) {
+func needOneArg(n *ir.CallExpr, f string, args ...any) (ir.Node, bool) {
if len(n.Args) == 0 {
p := fmt.Sprintf(f, args...)
base.Errorf("missing argument to %s: %v", p, n)
diff --git a/src/cmd/compile/internal/types/fmt.go b/src/cmd/compile/internal/types/fmt.go
index 67e2e99f02..848720ee89 100644
--- a/src/cmd/compile/internal/types/fmt.go
+++ b/src/cmd/compile/internal/types/fmt.go
@@ -183,7 +183,7 @@ var BasicTypeNames = []string{
}
var fmtBufferPool = sync.Pool{
- New: func() interface{} {
+ New: func() any {
return new(bytes.Buffer)
},
}
diff --git a/src/cmd/compile/internal/types/sizeof_test.go b/src/cmd/compile/internal/types/sizeof_test.go
index ba033ec499..1b80659c8e 100644
--- a/src/cmd/compile/internal/types/sizeof_test.go
+++ b/src/cmd/compile/internal/types/sizeof_test.go
@@ -16,9 +16,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
}{
{Sym{}, 32, 64},
{Type{}, 60, 96},
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go
index da859290f7..8de589bae3 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -174,7 +174,7 @@ type Type struct {
// TARRAY: *Array
// TSLICE: Slice
// TSSA: string
- extra interface{}
+ extra any
// width is the width of this Type in bytes.
width int64 // valid if Align > 0
diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go
index 8b27d9d3c1..77c59451fd 100644
--- a/src/cmd/compile/internal/types2/check.go
+++ b/src/cmd/compile/internal/types2/check.go
@@ -118,7 +118,7 @@ type action struct {
// If debug is set, describef sets a printf-formatted description for action a.
// Otherwise, it is a no-op.
-func (a *action) describef(pos poser, format string, args ...interface{}) {
+func (a *action) describef(pos poser, format string, args ...any) {
if debug {
a.desc = &actionDesc{pos, format, args}
}
@@ -129,7 +129,7 @@ func (a *action) describef(pos poser, format string, args ...interface{}) {
type actionDesc struct {
pos poser
format string
- args []interface{}
+ args []any
}
// A Checker maintains the state of the type checker.
diff --git a/src/cmd/compile/internal/types2/errors.go b/src/cmd/compile/internal/types2/errors.go
index 44f2adc7b7..e2f5508a1a 100644
--- a/src/cmd/compile/internal/types2/errors.go
+++ b/src/cmd/compile/internal/types2/errors.go
@@ -56,7 +56,7 @@ func (check *Checker) newError(code Code) *error_ {
// Subsequent calls to addf provide additional information in the form of additional lines
// in the error message (types2) or continuation errors identified by a tab-indented error
// message (go/types).
-func (err *error_) addf(at poser, format string, args ...interface{}) {
+func (err *error_) addf(at poser, format string, args ...any) {
err.desc = append(err.desc, errorDesc{atPos(at), err.check.sprintf(format, args...)})
}
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go
index d62b024757..39bf4055a3 100644
--- a/src/cmd/compile/internal/types2/expr.go
+++ b/src/cmd/compile/internal/types2/expr.go
@@ -1247,7 +1247,7 @@ Error:
// represented as an integer (such as 1.0) it is returned as an integer value.
// This ensures that constants of different kind but equal value (such as
// 1.0 + 0i, 1.0, 1) result in the same value.
-func keyVal(x constant.Value) interface{} {
+func keyVal(x constant.Value) any {
switch x.Kind() {
case constant.Complex:
f := constant.ToFloat(x)
diff --git a/src/cmd/compile/internal/types2/hilbert_test.go b/src/cmd/compile/internal/types2/hilbert_test.go
index df8a3e7d78..6cc0974c33 100644
--- a/src/cmd/compile/internal/types2/hilbert_test.go
+++ b/src/cmd/compile/internal/types2/hilbert_test.go
@@ -68,7 +68,7 @@ type gen struct {
bytes.Buffer
}
-func (g *gen) p(format string, args ...interface{}) {
+func (g *gen) p(format string, args ...any) {
fmt.Fprintf(&g.Buffer, format, args...)
}
diff --git a/src/cmd/compile/internal/types2/sizeof_test.go b/src/cmd/compile/internal/types2/sizeof_test.go
index 13b9620911..092e82318a 100644
--- a/src/cmd/compile/internal/types2/sizeof_test.go
+++ b/src/cmd/compile/internal/types2/sizeof_test.go
@@ -15,9 +15,9 @@ func TestSizeof(t *testing.T) {
const _64bit = ^uint(0)>>32 != 0
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
}{
// Types
{Basic{}, 16, 32},
diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go
index a579c8184e..f778a01a7a 100644
--- a/src/cmd/compile/internal/types2/stdlib_test.go
+++ b/src/cmd/compile/internal/types2/stdlib_test.go
@@ -460,7 +460,7 @@ func pkgFilenames(dir string, includeTest bool) ([]string, error) {
return filenames, nil
}
-func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...interface{})) {
+func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...any)) {
w := walker{pkgh, errh}
w.walk(dir)
}
diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go
index efe9c99d87..47ca4d90ec 100644
--- a/src/cmd/compile/internal/types2/stmt.go
+++ b/src/cmd/compile/internal/types2/stmt.go
@@ -192,7 +192,7 @@ func (check *Checker) suspendedCall(keyword string, call syntax.Expr) {
}
// goVal returns the Go value for val, or nil.
-func goVal(val constant.Value) interface{} {
+func goVal(val constant.Value) any {
// val should exist, but be conservative and check
if val == nil {
return nil
@@ -226,7 +226,7 @@ func goVal(val constant.Value) interface{} {
// types we need to also check the value's types (e.g., byte(1) vs myByte(1))
// when the switch expression is of interface type.
type (
- valueMap map[interface{}][]valueType // underlying Go value -> valueType
+ valueMap map[any][]valueType // underlying Go value -> valueType
valueType struct {
pos syntax.Pos
typ Type
diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go
index f4f24f4d1b..7250d82478 100644
--- a/src/cmd/compile/internal/types2/unify.go
+++ b/src/cmd/compile/internal/types2/unify.go
@@ -141,7 +141,7 @@ func (u *unifier) unify(x, y Type, mode unifyMode) bool {
return u.nify(x, y, mode, nil)
}
-func (u *unifier) tracef(format string, args ...interface{}) {
+func (u *unifier) tracef(format string, args ...any) {
fmt.Println(strings.Repeat(". ", u.depth) + sprintf(nil, true, format, args...))
}
diff --git a/src/cmd/compile/internal/types2/version.go b/src/cmd/compile/internal/types2/version.go
index 765b0f7e9a..512285055c 100644
--- a/src/cmd/compile/internal/types2/version.go
+++ b/src/cmd/compile/internal/types2/version.go
@@ -58,7 +58,7 @@ func (check *Checker) allowVersion(want goVersion) bool {
// verifyVersionf is like allowVersion but also accepts a format string and arguments
// which are used to report a version error if allowVersion returns false.
-func (check *Checker) verifyVersionf(at poser, v goVersion, format string, args ...interface{}) bool {
+func (check *Checker) verifyVersionf(at poser, v goVersion, format string, args ...any) bool {
if !check.allowVersion(v) {
check.versionErrorf(at, v, format, args...)
return false
diff --git a/src/cmd/covdata/covdata.go b/src/cmd/covdata/covdata.go
index 122ad28b5c..b88b81799e 100644
--- a/src/cmd/covdata/covdata.go
+++ b/src/cmd/covdata/covdata.go
@@ -42,14 +42,14 @@ func Exit(code int) {
os.Exit(code)
}
-func dbgtrace(vlevel int, s string, a ...interface{}) {
+func dbgtrace(vlevel int, s string, a ...any) {
if *verbflag >= vlevel {
fmt.Printf(s, a...)
fmt.Printf("\n")
}
}
-func warn(s string, a ...interface{}) {
+func warn(s string, a ...any) {
fmt.Fprintf(os.Stderr, "warning: ")
fmt.Fprintf(os.Stderr, s, a...)
fmt.Fprintf(os.Stderr, "\n")
@@ -58,7 +58,7 @@ func warn(s string, a ...interface{}) {
}
}
-func fatal(s string, a ...interface{}) {
+func fatal(s string, a ...any) {
fmt.Fprintf(os.Stderr, "error: ")
fmt.Fprintf(os.Stderr, s, a...)
fmt.Fprintf(os.Stderr, "\n")
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 9c9e1b85f0..15cfcccec3 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -1108,7 +1108,7 @@ func (t *tester) registerTest(heading string, test *goTest, opts ...registerTest
// dirCmd constructs a Cmd intended to be run in the foreground.
// The command will be run in dir, and Stdout and Stderr will go to os.Stdout
// and os.Stderr.
-func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd {
+func (t *tester) dirCmd(dir string, cmdline ...any) *exec.Cmd {
bin, args := flattenCmdline(cmdline)
cmd := exec.Command(bin, args...)
if filepath.IsAbs(dir) {
@@ -1126,7 +1126,7 @@ func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd {
// flattenCmdline flattens a mixture of string and []string as single list
// and then interprets it as a command line: first element is binary, then args.
-func flattenCmdline(cmdline []interface{}) (bin string, args []string) {
+func flattenCmdline(cmdline []any) (bin string, args []string) {
var list []string
for _, x := range cmdline {
switch x := x.(type) {
diff --git a/src/cmd/dist/util.go b/src/cmd/dist/util.go
index 121c2dc62c..1109bf0efd 100644
--- a/src/cmd/dist/util.go
+++ b/src/cmd/dist/util.go
@@ -21,7 +21,7 @@ import (
// pathf is fmt.Sprintf for generating paths
// (on windows it turns / into \ after the printf).
-func pathf(format string, args ...interface{}) string {
+func pathf(format string, args ...any) string {
return filepath.Clean(fmt.Sprintf(format, args...))
}
@@ -324,7 +324,7 @@ func xworkdir() string {
}
// fatalf prints an error message to standard error and exits.
-func fatalf(format string, args ...interface{}) {
+func fatalf(format string, args ...any) {
fmt.Fprintf(os.Stderr, "go tool dist: %s\n", fmt.Sprintf(format, args...))
dieOnce.Do(func() { close(dying) })
@@ -353,12 +353,12 @@ func xatexit(f func()) {
}
// xprintf prints a message to standard output.
-func xprintf(format string, args ...interface{}) {
+func xprintf(format string, args ...any) {
fmt.Printf(format, args...)
}
// errprintf prints a message to standard output.
-func errprintf(format string, args ...interface{}) {
+func errprintf(format string, args ...any) {
fmt.Fprintf(os.Stderr, format, args...)
}
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go
index 3998ce1172..0ec4102cc6 100644
--- a/src/cmd/go/internal/modload/import.go
+++ b/src/cmd/go/internal/modload/import.go
@@ -268,7 +268,7 @@ func (e *invalidImportError) Unwrap() error {
// 1.20, preventing unnecessary go.sum churn and network access in those
// modules.
func importFromModules(loaderstate *State, ctx context.Context, path string, rs *Requirements, mg *ModuleGraph, skipModFile bool) (m module.Version, modroot, dir string, altMods []module.Version, err error) {
- invalidf := func(format string, args ...interface{}) (module.Version, string, string, []module.Version, error) {
+ invalidf := func(format string, args ...any) (module.Version, string, string, []module.Version, error) {
return module.Version{}, "", "", nil, &invalidImportError{
importPath: path,
err: fmt.Errorf(format, args...),
diff --git a/src/cmd/internal/cov/readcovdata.go b/src/cmd/internal/cov/readcovdata.go
index e0e0634459..f9fd522930 100644
--- a/src/cmd/internal/cov/readcovdata.go
+++ b/src/cmd/internal/cov/readcovdata.go
@@ -145,14 +145,14 @@ func (r *CovDataReader) Visit() error {
return nil
}
-func (r *CovDataReader) verb(vlevel int, s string, a ...interface{}) {
+func (r *CovDataReader) verb(vlevel int, s string, a ...any) {
if r.verbosityLevel >= vlevel {
fmt.Fprintf(os.Stderr, s, a...)
fmt.Fprintf(os.Stderr, "\n")
}
}
-func (r *CovDataReader) warn(s string, a ...interface{}) {
+func (r *CovDataReader) warn(s string, a ...any) {
fmt.Fprintf(os.Stderr, "warning: ")
fmt.Fprintf(os.Stderr, s, a...)
fmt.Fprintf(os.Stderr, "\n")
@@ -161,7 +161,7 @@ func (r *CovDataReader) warn(s string, a ...interface{}) {
}
}
-func (r *CovDataReader) fatal(s string, a ...interface{}) error {
+func (r *CovDataReader) fatal(s string, a ...any) error {
if r.err != nil {
return nil
}
diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go
index 6e06f139b0..b8956b4cff 100644
--- a/src/cmd/internal/dwarf/dwarf.go
+++ b/src/cmd/internal/dwarf/dwarf.go
@@ -40,8 +40,7 @@ const AbstractFuncSuffix = "$abstract"
var logDwarf bool
// Sym represents a symbol.
-type Sym interface {
-}
+type Sym any
// A Var represents a local variable or a function parameter.
type Var struct {
@@ -194,16 +193,16 @@ type Context interface {
Size(s Sym) int64
AddInt(s Sym, size int, i int64)
AddBytes(s Sym, b []byte)
- AddAddress(s Sym, t interface{}, ofs int64)
- AddCURelativeAddress(s Sym, t interface{}, ofs int64)
- AddSectionOffset(s Sym, size int, t interface{}, ofs int64)
- AddDWARFAddrSectionOffset(s Sym, t interface{}, ofs int64)
- AddIndirectTextRef(s Sym, t interface{})
+ AddAddress(s Sym, t any, ofs int64)
+ AddCURelativeAddress(s Sym, t any, ofs int64)
+ AddSectionOffset(s Sym, size int, t any, ofs int64)
+ AddDWARFAddrSectionOffset(s Sym, t any, ofs int64)
+ AddIndirectTextRef(s Sym, t any)
CurrentOffset(s Sym) int64
RecordDclReference(from Sym, to Sym, dclIdx int, inlIndex int)
RecordChildDieOffsets(s Sym, vars []*Var, offsets []int32)
AddString(s Sym, v string)
- Logf(format string, args ...interface{})
+ Logf(format string, args ...any)
}
// AppendUleb128 appends v to b using DWARF's unsigned LEB128 encoding.
@@ -874,7 +873,7 @@ type DWAttr struct {
Atr uint16 // DW_AT_
Cls uint8 // DW_CLS_
Value int64
- Data interface{}
+ Data any
}
// DWDie represents a DWARF debug info entry.
@@ -886,7 +885,7 @@ type DWDie struct {
Sym Sym
}
-func putattr(ctxt Context, s Sym, abbrev int, form int, cls int, value int64, data interface{}) error {
+func putattr(ctxt Context, s Sym, abbrev int, form int, cls int, value int64, data any) error {
switch form {
case DW_FORM_addr: // address
// Allow nil addresses for DW_AT_go_runtime_type.
diff --git a/src/cmd/internal/macho/macho.go b/src/cmd/internal/macho/macho.go
index ad29c32c50..6c9907dbb4 100644
--- a/src/cmd/internal/macho/macho.go
+++ b/src/cmd/internal/macho/macho.go
@@ -100,7 +100,7 @@ func (r *LoadCmdReader) Next() (LoadCmd, error) {
return cmd, nil
}
-func (r LoadCmdReader) ReadAt(offset int64, data interface{}) error {
+func (r LoadCmdReader) ReadAt(offset int64, data any) error {
if _, err := r.f.Seek(r.offset+offset, 0); err != nil {
return err
}
@@ -117,7 +117,7 @@ func NewLoadCmdUpdater(f io.ReadWriteSeeker, order binary.ByteOrder, nextOffset
return LoadCmdUpdater{NewLoadCmdReader(f, order, nextOffset)}
}
-func (u LoadCmdUpdater) WriteAt(offset int64, data interface{}) error {
+func (u LoadCmdUpdater) WriteAt(offset int64, data any) error {
if _, err := u.f.Seek(u.offset+offset, 0); err != nil {
return err
}
diff --git a/src/cmd/internal/obj/dwarf.go b/src/cmd/internal/obj/dwarf.go
index 670b0f3510..d09aa985f0 100644
--- a/src/cmd/internal/obj/dwarf.go
+++ b/src/cmd/internal/obj/dwarf.go
@@ -231,7 +231,7 @@ func (c dwCtxt) AddString(s dwarf.Sym, v string) {
ls.WriteString(c.Link, ls.Size, len(v), v)
ls.WriteInt(c.Link, ls.Size, 1, 0)
}
-func (c dwCtxt) AddAddress(s dwarf.Sym, data interface{}, value int64) {
+func (c dwCtxt) AddAddress(s dwarf.Sym, data any, value int64) {
ls := s.(*LSym)
size := c.PtrSize()
if data != nil {
@@ -241,15 +241,15 @@ func (c dwCtxt) AddAddress(s dwarf.Sym, data interface{}, value int64) {
ls.WriteInt(c.Link, ls.Size, size, value)
}
}
-func (c dwCtxt) AddCURelativeAddress(s dwarf.Sym, data interface{}, value int64) {
+func (c dwCtxt) AddCURelativeAddress(s dwarf.Sym, data any, value int64) {
ls := s.(*LSym)
rsym := data.(*LSym)
ls.WriteCURelativeAddr(c.Link, ls.Size, rsym, value)
}
-func (c dwCtxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64) {
+func (c dwCtxt) AddSectionOffset(s dwarf.Sym, size int, t any, ofs int64) {
panic("should be used only in the linker")
}
-func (c dwCtxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t interface{}, ofs int64) {
+func (c dwCtxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t any, ofs int64) {
size := 4
if isDwarf64(c.Link) {
size = 8
@@ -284,11 +284,11 @@ func (c dwCtxt) RecordChildDieOffsets(s dwarf.Sym, vars []*dwarf.Var, offsets []
c.Link.DwFixups.RegisterChildDIEOffsets(ls, vars, offsets)
}
-func (c dwCtxt) Logf(format string, args ...interface{}) {
+func (c dwCtxt) Logf(format string, args ...any) {
c.Link.Logf(format, args...)
}
-func (c dwCtxt) AddIndirectTextRef(s dwarf.Sym, t interface{}) {
+func (c dwCtxt) AddIndirectTextRef(s dwarf.Sym, t any) {
ls := s.(*LSym)
tsym := t.(*LSym)
// Note the doubling below -- DwTextCount is an estimate and
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index 9f3814e748..85dca33d27 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -211,7 +211,7 @@ type Addr struct {
// for TYPE_FCONST, a float64
// for TYPE_BRANCH, a *Prog (optional)
// for TYPE_TEXTSIZE, an int32 (optional)
- Val interface{}
+ Val any
}
type AddrName int8
@@ -464,7 +464,7 @@ type LSym struct {
P []byte
R []Reloc
- Extra *interface{} // *FuncInfo, *VarInfo, *FileInfo, *TypeInfo, or *ItabInfo, if present
+ Extra *any // *FuncInfo, *VarInfo, *FileInfo, *TypeInfo, or *ItabInfo, if present
Pkg string
PkgIdx int32
@@ -523,7 +523,7 @@ func (s *LSym) NewFuncInfo() *FuncInfo {
panic(fmt.Sprintf("invalid use of LSym - NewFuncInfo with Extra of type %T", *s.Extra))
}
f := new(FuncInfo)
- s.Extra = new(interface{})
+ s.Extra = new(any)
*s.Extra = f
return f
}
@@ -547,7 +547,7 @@ func (s *LSym) NewVarInfo() *VarInfo {
panic(fmt.Sprintf("invalid use of LSym - NewVarInfo with Extra of type %T", *s.Extra))
}
f := new(VarInfo)
- s.Extra = new(interface{})
+ s.Extra = new(any)
*s.Extra = f
return f
}
@@ -574,7 +574,7 @@ func (s *LSym) NewFileInfo() *FileInfo {
panic(fmt.Sprintf("invalid use of LSym - NewFileInfo with Extra of type %T", *s.Extra))
}
f := new(FileInfo)
- s.Extra = new(interface{})
+ s.Extra = new(any)
*s.Extra = f
return f
}
@@ -591,7 +591,7 @@ func (s *LSym) File() *FileInfo {
// A TypeInfo contains information for a symbol
// that contains a runtime._type.
type TypeInfo struct {
- Type interface{} // a *cmd/compile/internal/types.Type
+ Type any // a *cmd/compile/internal/types.Type
}
func (s *LSym) NewTypeInfo() *TypeInfo {
@@ -599,7 +599,7 @@ func (s *LSym) NewTypeInfo() *TypeInfo {
panic(fmt.Sprintf("invalid use of LSym - NewTypeInfo with Extra of type %T", *s.Extra))
}
t := new(TypeInfo)
- s.Extra = new(interface{})
+ s.Extra = new(any)
*s.Extra = t
return t
}
@@ -616,7 +616,7 @@ func (s *LSym) TypeInfo() *TypeInfo {
// An ItabInfo contains information for a symbol
// that contains a runtime.itab.
type ItabInfo struct {
- Type interface{} // a *cmd/compile/internal/types.Type
+ Type any // a *cmd/compile/internal/types.Type
}
func (s *LSym) NewItabInfo() *ItabInfo {
@@ -624,7 +624,7 @@ func (s *LSym) NewItabInfo() *ItabInfo {
panic(fmt.Sprintf("invalid use of LSym - NewItabInfo with Extra of type %T", *s.Extra))
}
t := new(ItabInfo)
- s.Extra = new(interface{})
+ s.Extra = new(any)
*s.Extra = t
return t
}
@@ -1178,7 +1178,7 @@ type Link struct {
DwFixups *DwarfFixupTable
DwTextCount int
Imports []goobj.ImportedPkg
- DiagFunc func(string, ...interface{})
+ DiagFunc func(string, ...any)
DiagFlush func()
DebugInfo func(ctxt *Link, fn *LSym, info *LSym, curfn Func) ([]dwarf.Scope, dwarf.InlCalls)
GenAbstractFunc func(fn *LSym)
@@ -1223,12 +1223,12 @@ func _(ctxt *Link) {
}
}
-func (ctxt *Link) Diag(format string, args ...interface{}) {
+func (ctxt *Link) Diag(format string, args ...any) {
ctxt.Errors++
ctxt.DiagFunc(format, args...)
}
-func (ctxt *Link) Logf(format string, args ...interface{}) {
+func (ctxt *Link) Logf(format string, args ...any) {
fmt.Fprintf(ctxt.Bso, format, args...)
ctxt.Bso.Flush()
}
diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go
index e0aca15005..53cea8d37c 100644
--- a/src/cmd/internal/obj/loong64/asm.go
+++ b/src/cmd/internal/obj/loong64/asm.go
@@ -1340,7 +1340,7 @@ func opset(a, b0 obj.As) {
func buildop(ctxt *obj.Link) {
if ctxt.DiagFunc == nil {
- ctxt.DiagFunc = func(format string, args ...interface{}) {
+ ctxt.DiagFunc = func(format string, args ...any) {
log.Printf(format, args...)
}
}
diff --git a/src/cmd/internal/obj/pcln.go b/src/cmd/internal/obj/pcln.go
index 67a078091c..1cfcde7aa5 100644
--- a/src/cmd/internal/obj/pcln.go
+++ b/src/cmd/internal/obj/pcln.go
@@ -22,7 +22,7 @@ import (
//
// where func is the function, val is the current value, p is the instruction being
// considered, and arg can be used to further parameterize valfunc.
-func funcpctab(ctxt *Link, func_ *LSym, desc string, valfunc func(*Link, *LSym, int32, *Prog, int32, interface{}) int32, arg interface{}) *LSym {
+func funcpctab(ctxt *Link, func_ *LSym, desc string, valfunc func(*Link, *LSym, int32, *Prog, int32, any) int32, arg any) *LSym {
dbg := desc == ctxt.Debugpcln
dst := []byte{}
sym := &LSym{
@@ -138,7 +138,7 @@ func funcpctab(ctxt *Link, func_ *LSym, desc string, valfunc func(*Link, *LSym,
// or the line number (arg == 1) to use at p.
// Because p.Pos applies to p, phase == 0 (before p)
// takes care of the update.
-func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
+func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg any) int32 {
if p.As == ATEXT || p.As == ANOP || p.Pos.Line() == 0 || phase == 1 {
return oldval
}
@@ -198,7 +198,7 @@ func (s *pcinlineState) setParentPC(ctxt *Link, globalIndex int, pc int32) {
// pctoinline computes the index into the local inlining tree to use at p.
// If p is not the result of inlining, pctoinline returns -1. Because p.Pos
// applies to p, phase == 0 (before p) takes care of the update.
-func (s *pcinlineState) pctoinline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
+func (s *pcinlineState) pctoinline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg any) int32 {
if phase == 1 {
return oldval
}
@@ -224,7 +224,7 @@ func (s *pcinlineState) pctoinline(ctxt *Link, sym *LSym, oldval int32, p *Prog,
// It is oldval plus any adjustment made by p itself.
// The adjustment by p takes effect only after p, so we
// apply the change during phase == 1.
-func pctospadj(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
+func pctospadj(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg any) int32 {
if oldval == -1 { // starting
oldval = 0
}
@@ -245,7 +245,7 @@ func pctospadj(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg in
// non-PCDATA instructions.
// Since PCDATA instructions have no width in the final code,
// it does not matter which phase we use for the update.
-func pctopcdata(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
+func pctopcdata(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg any) int32 {
if phase == 0 || p.As != APCDATA || p.From.Offset != int64(arg.(uint32)) {
return oldval
}
@@ -337,7 +337,7 @@ func linkpcln(ctxt *Link, cursym *LSym) {
Attribute: AttrContentAddressable | AttrPcdata,
}
} else {
- pcln.Pcdata[i] = funcpctab(ctxt, cursym, "pctopcdata", pctopcdata, interface{}(uint32(i)))
+ pcln.Pcdata[i] = funcpctab(ctxt, cursym, "pctopcdata", pctopcdata, any(uint32(i)))
}
}
diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go
index ab7af2205e..9f1acf4b62 100644
--- a/src/cmd/internal/obj/ppc64/asm_test.go
+++ b/src/cmd/internal/obj/ppc64/asm_test.go
@@ -439,7 +439,7 @@ func TestAddrClassifier(t *testing.T) {
}
tsts := [...]struct {
arg obj.Addr
- output interface{}
+ output any
}{
// Supported register type args
{obj.Addr{Type: obj.TYPE_REG, Reg: REG_R1}, C_REG},
diff --git a/src/cmd/internal/obj/sizeof_test.go b/src/cmd/internal/obj/sizeof_test.go
index 69e60473f5..fdee114f5b 100644
--- a/src/cmd/internal/obj/sizeof_test.go
+++ b/src/cmd/internal/obj/sizeof_test.go
@@ -16,9 +16,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
}{
{Addr{}, 32, 48},
{LSym{}, 72, 120},
diff --git a/src/cmd/internal/objabi/flag.go b/src/cmd/internal/objabi/flag.go
index 8709c4e5cf..32d71d0575 100644
--- a/src/cmd/internal/objabi/flag.go
+++ b/src/cmd/internal/objabi/flag.go
@@ -85,7 +85,7 @@ var buildID string // filled in by linker
type versionFlag struct{}
func (versionFlag) IsBoolFlag() bool { return true }
-func (versionFlag) Get() interface{} { return nil }
+func (versionFlag) Get() any { return nil }
func (versionFlag) String() string { return "" }
func (versionFlag) Set(s string) error {
name := os.Args[0]
@@ -148,7 +148,7 @@ func (c *count) Set(s string) error {
return nil
}
-func (c *count) Get() interface{} {
+func (c *count) Get() any {
return int(*c)
}
@@ -206,8 +206,8 @@ func DecodeArg(arg string) string {
type debugField struct {
name string
help string
- concurrentOk bool // true if this field/flag is compatible with concurrent compilation
- val interface{} // *int or *string
+ concurrentOk bool // true if this field/flag is compatible with concurrent compilation
+ val any // *int or *string
}
type DebugFlag struct {
@@ -234,7 +234,7 @@ type DebugSSA func(phase, flag string, val int, valString string) string
//
// If debugSSA is non-nil, any debug flags of the form ssa/... will be
// passed to debugSSA for processing.
-func NewDebugFlag(debug interface{}, debugSSA DebugSSA) *DebugFlag {
+func NewDebugFlag(debug any, debugSSA DebugSSA) *DebugFlag {
flag := &DebugFlag{
tab: make(map[string]debugField),
debugSSA: debugSSA,
diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go
index 222e712ede..31de34aff4 100644
--- a/src/cmd/link/internal/ld/dwarf.go
+++ b/src/cmd/link/internal/ld/dwarf.go
@@ -100,7 +100,7 @@ func (c dwctxt) AddString(s dwarf.Sym, v string) {
dsu.Addstring(v)
}
-func (c dwctxt) AddAddress(s dwarf.Sym, data interface{}, value int64) {
+func (c dwctxt) AddAddress(s dwarf.Sym, data any, value int64) {
ds := loader.Sym(s.(dwSym))
dsu := c.ldr.MakeSymbolUpdater(ds)
if value != 0 {
@@ -110,7 +110,7 @@ func (c dwctxt) AddAddress(s dwarf.Sym, data interface{}, value int64) {
dsu.AddAddrPlus(c.arch, tgtds, value)
}
-func (c dwctxt) AddCURelativeAddress(s dwarf.Sym, data interface{}, value int64) {
+func (c dwctxt) AddCURelativeAddress(s dwarf.Sym, data any, value int64) {
ds := loader.Sym(s.(dwSym))
dsu := c.ldr.MakeSymbolUpdater(ds)
if value != 0 {
@@ -120,7 +120,7 @@ func (c dwctxt) AddCURelativeAddress(s dwarf.Sym, data interface{}, value int64)
dsu.AddCURelativeAddrPlus(c.arch, tgtds, value)
}
-func (c dwctxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64) {
+func (c dwctxt) AddSectionOffset(s dwarf.Sym, size int, t any, ofs int64) {
ds := loader.Sym(s.(dwSym))
dsu := c.ldr.MakeSymbolUpdater(ds)
tds := loader.Sym(t.(dwSym))
@@ -132,7 +132,7 @@ func (c dwctxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64
dsu.AddSymRef(c.arch, tds, ofs, objabi.R_ADDROFF, size)
}
-func (c dwctxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t interface{}, ofs int64) {
+func (c dwctxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t any, ofs int64) {
size := 4
if isDwarf64(c.linkctxt) {
size = 8
@@ -148,14 +148,14 @@ func (c dwctxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t interface{}, ofs int64)
dsu.AddSymRef(c.arch, tds, ofs, objabi.R_DWARFSECREF, size)
}
-func (c dwctxt) AddIndirectTextRef(s dwarf.Sym, t interface{}) {
+func (c dwctxt) AddIndirectTextRef(s dwarf.Sym, t any) {
ds := loader.Sym(s.(dwSym))
dsu := c.ldr.MakeSymbolUpdater(ds)
tds := loader.Sym(t.(dwSym))
dsu.AddSymRef(c.arch, tds, 0, objabi.R_DWTXTADDR_U4, 4)
}
-func (c dwctxt) Logf(format string, args ...interface{}) {
+func (c dwctxt) Logf(format string, args ...any) {
c.linkctxt.Logf(format, args...)
}
@@ -239,7 +239,7 @@ var dwtypes dwarf.DWDie
// up all attrs in a single large table, then store indices into the
// table in the DIE. This would allow us to common up storage for
// attributes that are shared by many DIEs (ex: byte size of N).
-func newattr(die *dwarf.DWDie, attr uint16, cls int, value int64, data interface{}) {
+func newattr(die *dwarf.DWDie, attr uint16, cls int, value int64, data any) {
a := new(dwarf.DWAttr)
a.Link = die.Attr
die.Attr = a
diff --git a/src/cmd/link/internal/ld/link.go b/src/cmd/link/internal/ld/link.go
index df1fc7feab..2276d39d88 100644
--- a/src/cmd/link/internal/ld/link.go
+++ b/src/cmd/link/internal/ld/link.go
@@ -126,7 +126,7 @@ type cgodata struct {
directives [][]string
}
-func (ctxt *Link) Logf(format string, args ...interface{}) {
+func (ctxt *Link) Logf(format string, args ...any) {
fmt.Fprintf(ctxt.Bso, format, args...)
ctxt.Bso.Flush()
}
diff --git a/src/cmd/link/internal/ld/macho_combine_dwarf.go b/src/cmd/link/internal/ld/macho_combine_dwarf.go
index d60755f147..2b303cbdae 100644
--- a/src/cmd/link/internal/ld/macho_combine_dwarf.go
+++ b/src/cmd/link/internal/ld/macho_combine_dwarf.go
@@ -392,7 +392,7 @@ func machoUpdateDwarfHeader(r *imacho.LoadCmdUpdater, compressedSects []*macho.S
return machoUpdateSections(*r, &seg, uint64(dwarfstart)-realdwarf.Offset, compressedSects)
}
-func machoUpdateLoadCommand(r imacho.LoadCmdUpdater, linkseg *macho.Segment, linkoffset uint64, cmd interface{}, fields ...string) error {
+func machoUpdateLoadCommand(r imacho.LoadCmdUpdater, linkseg *macho.Segment, linkoffset uint64, cmd any, fields ...string) error {
if err := r.ReadAt(0, cmd); err != nil {
return err
}
diff --git a/src/cmd/link/internal/ld/util.go b/src/cmd/link/internal/ld/util.go
index 556c77d732..f3787ff50b 100644
--- a/src/cmd/link/internal/ld/util.go
+++ b/src/cmd/link/internal/ld/util.go
@@ -32,7 +32,7 @@ func Exit(code int) {
}
// Exitf logs an error message then calls Exit(2).
-func Exitf(format string, a ...interface{}) {
+func Exitf(format string, a ...any) {
fmt.Fprintf(os.Stderr, os.Args[0]+": "+format+"\n", a...)
nerrors++
if *flagH {
@@ -60,7 +60,7 @@ func afterErrorAction() {
//
// Logging an error means that on exit cmd/link will delete any
// output file and return a non-zero error code.
-func Errorf(format string, args ...interface{}) {
+func Errorf(format string, args ...any) {
format += "\n"
fmt.Fprintf(os.Stderr, format, args...)
afterErrorAction()
@@ -72,7 +72,7 @@ func Errorf(format string, args ...interface{}) {
//
// Logging an error means that on exit cmd/link will delete any
// output file and return a non-zero error code.
-func (ctxt *Link) Errorf(s loader.Sym, format string, args ...interface{}) {
+func (ctxt *Link) Errorf(s loader.Sym, format string, args ...any) {
if ctxt.loader != nil {
ctxt.loader.Errorf(s, format, args...)
return
diff --git a/src/cmd/link/internal/ld/xcoff.go b/src/cmd/link/internal/ld/xcoff.go
index fc98fcba2b..4500a7cb0c 100644
--- a/src/cmd/link/internal/ld/xcoff.go
+++ b/src/cmd/link/internal/ld/xcoff.go
@@ -167,8 +167,7 @@ const (
)
// Type representing all XCOFF symbols.
-type xcoffSym interface {
-}
+type xcoffSym any
// Symbol Table Entry
type XcoffSymEnt64 struct {
diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go
index 9434704be4..1c83f03a5d 100644
--- a/src/cmd/link/internal/loadelf/ldelf.go
+++ b/src/cmd/link/internal/loadelf/ldelf.go
@@ -242,7 +242,7 @@ func parseArmAttributes(e binary.ByteOrder, data []byte) (found bool, ehdrFlags
// object, and the returned ehdrFlags contains what this Load function computes.
// TODO: find a better place for this logic.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, pkg string, length int64, pn string, initEhdrFlags uint32) (textp []loader.Sym, ehdrFlags uint32, err error) {
- errorf := func(str string, args ...interface{}) ([]loader.Sym, uint32, error) {
+ errorf := func(str string, args ...any) ([]loader.Sym, uint32, error) {
return nil, 0, fmt.Errorf("loadelf: %s: %v", pn, fmt.Sprintf(str, args...))
}
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index a612a1ac81..2d386c0c65 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -2821,7 +2821,7 @@ type ErrorReporter struct {
//
// Logging an error means that on exit cmd/link will delete any
// output file and return a non-zero error code.
-func (reporter *ErrorReporter) Errorf(s Sym, format string, args ...interface{}) {
+func (reporter *ErrorReporter) Errorf(s Sym, format string, args ...any) {
if s != 0 && reporter.ldr.SymName(s) != "" {
// Note: Replace is needed here because symbol names might have % in them,
// due to the use of LinkString for names of instantiating types.
@@ -2840,7 +2840,7 @@ func (l *Loader) GetErrorReporter() *ErrorReporter {
}
// Errorf method logs an error message. See ErrorReporter.Errorf for details.
-func (l *Loader) Errorf(s Sym, format string, args ...interface{}) {
+func (l *Loader) Errorf(s Sym, format string, args ...any) {
l.errorReporter.Errorf(s, format, args...)
}
diff --git a/src/cmd/link/internal/loadmacho/ldmacho.go b/src/cmd/link/internal/loadmacho/ldmacho.go
index dcb0fd92c1..ecd0150943 100644
--- a/src/cmd/link/internal/loadmacho/ldmacho.go
+++ b/src/cmd/link/internal/loadmacho/ldmacho.go
@@ -424,7 +424,7 @@ func macholoadsym(m *ldMachoObj, symtab *ldMachoSymtab) int {
// Load the Mach-O file pn from f.
// Symbols are written into syms, and a slice of the text symbols is returned.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, pkg string, length int64, pn string) (textp []loader.Sym, err error) {
- errorf := func(str string, args ...interface{}) ([]loader.Sym, error) {
+ errorf := func(str string, args ...any) ([]loader.Sym, error) {
return nil, fmt.Errorf("loadmacho: %v: %v", pn, fmt.Sprintf(str, args...))
}
diff --git a/src/cmd/link/internal/loadxcoff/ldxcoff.go b/src/cmd/link/internal/loadxcoff/ldxcoff.go
index fd116d5420..8c0949ec70 100644
--- a/src/cmd/link/internal/loadxcoff/ldxcoff.go
+++ b/src/cmd/link/internal/loadxcoff/ldxcoff.go
@@ -42,7 +42,7 @@ func (f *xcoffBiobuf) ReadAt(p []byte, off int64) (int, error) {
// loads the Xcoff file pn from f.
// Symbols are written into loader, and a slice of the text symbols is returned.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Reader, pkg string, length int64, pn string) (textp []loader.Sym, err error) {
- errorf := func(str string, args ...interface{}) ([]loader.Sym, error) {
+ errorf := func(str string, args ...any) ([]loader.Sym, error) {
return nil, fmt.Errorf("loadxcoff: %v: %v", pn, fmt.Sprintf(str, args...))
}
diff --git a/src/cmd/link/internal/sym/segment.go b/src/cmd/link/internal/sym/segment.go
index c889e71ad6..d397b84570 100644
--- a/src/cmd/link/internal/sym/segment.go
+++ b/src/cmd/link/internal/sym/segment.go
@@ -52,7 +52,7 @@ type Section struct {
Vaddr uint64
Length uint64
Seg *Segment
- Elfsect interface{} // an *ld.ElfShdr
+ Elfsect any // an *ld.ElfShdr
Reloff uint64
Rellen uint64
// Relcount is the number of *host* relocations applied to this section