diff --git a/src/cmd/asm/internal/asm/endtoend_test.go b/src/cmd/asm/internal/asm/endtoend_test.go
index 9571afc..e532633 100644
--- a/src/cmd/asm/internal/asm/endtoend_test.go
+++ b/src/cmd/asm/internal/asm/endtoend_test.go
@@ -38,7 +38,7 @@
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 @@
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 @@
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 545f6c7..25d596f 100644
--- a/src/cmd/asm/internal/asm/parse.go
+++ b/src/cmd/asm/internal/asm/parse.go
@@ -78,7 +78,7 @@
// 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 @@
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 789e229..342ac5a 100644
--- a/src/cmd/asm/internal/lex/input.go
+++ b/src/cmd/asm/internal/lex/input.go
@@ -68,7 +68,7 @@
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 @@
}
// 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 9db1fec..f2697db 100644
--- a/src/cmd/asm/main.go
+++ b/src/cmd/asm/main.go
@@ -93,7 +93,7 @@
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 97b18cd..2da6ca5 100644
--- a/src/cmd/cgo/ast.go
+++ b/src/cmd/cgo/ast.go
@@ -199,7 +199,7 @@
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 @@
}
// 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 @@
}
// 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 @@
}
// 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 @@
)
// 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 d1b6290..d3de390 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -1158,7 +1158,7 @@
// 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 @@
// 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 @@
// 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 @@
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 9cf626c..93f9027 100644
--- a/src/cmd/cgo/godefs.go
+++ b/src/cmd/cgo/godefs.go
@@ -117,7 +117,7 @@
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 2afb542..3216073 100644
--- a/src/cmd/cgo/internal/testplugin/plugin_test.go
+++ b/src/cmd/cgo/internal/testplugin/plugin_test.go
@@ -37,7 +37,7 @@
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 955d64b..ba8e52a 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -148,7 +148,7 @@
// 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 f0e0728..701a853 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -953,7 +953,7 @@
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 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 23b4a41..e83634f 100644
--- a/src/cmd/cgo/util.go
+++ b/src/cmd/cgo/util.go
@@ -75,7 +75,7 @@
}
// 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 @@
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 ddfca34..e41a6c0 100644
--- a/src/cmd/compile/internal/abt/avlint32.go
+++ b/src/cmd/compile/internal/abt/avlint32.go
@@ -28,7 +28,7 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
} else {
newroot, n, o = n.aInsert(x)
}
- var r interface{}
+ var r any
if o != nil {
r = o.data
} else {
@@ -121,7 +121,7 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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 7fa9ed4..7196244 100644
--- a/src/cmd/compile/internal/abt/avlint32_test.go
+++ b/src/cmd/compile/internal/abt/avlint32_test.go
@@ -317,7 +317,7 @@
}
}
-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 @@
[]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 @@
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 9e3348c..6bfc84c 100644
--- a/src/cmd/compile/internal/base/print.go
+++ b/src/cmd/compile/internal/base/print.go
@@ -45,7 +45,7 @@
}
// 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 @@
}
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
}
// 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 f48ac93..cbcd4dc 100644
--- a/src/cmd/compile/internal/base/timings.go
+++ b/src/cmd/compile/internal/base/timings.go
@@ -168,7 +168,7 @@
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 4c21868..3e5e6fb 100644
--- a/src/cmd/compile/internal/ir/dump.go
+++ b/src/cmd/compile/internal/ir/dump.go
@@ -21,7 +21,7 @@
)
// 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 @@
// 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 @@
}
// 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 668537c..e027fe8 100644
--- a/src/cmd/compile/internal/ir/func.go
+++ b/src/cmd/compile/internal/ir/func.go
@@ -90,7 +90,7 @@
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 6f8d0a7..01f1c0c 100644
--- a/src/cmd/compile/internal/ir/name.go
+++ b/src/cmd/compile/internal/ir/name.go
@@ -43,8 +43,8 @@
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 14b6b4f..b805155 100644
--- a/src/cmd/compile/internal/ir/sizeof_test.go
+++ b/src/cmd/compile/internal/ir/sizeof_test.go
@@ -16,9 +16,9 @@
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 d08f6fb..c47c9ee 100644
--- a/src/cmd/compile/internal/logopt/log_opts.go
+++ b/src/cmd/compile/internal/logopt/log_opts.go
@@ -224,12 +224,12 @@
// 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 @@
// 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 @@
// 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 @@
// 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 5a4590d..267df2f 100644
--- a/src/cmd/compile/internal/loopvar/loopvar.go
+++ b/src/cmd/compile/internal/loopvar/loopvar.go
@@ -557,7 +557,7 @@
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 9c90d22..0b5aa00 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -120,12 +120,12 @@
}
// 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 1240bfd..278a6b0 100644
--- a/src/cmd/compile/internal/ssa/block.go
+++ b/src/cmd/compile/internal/ssa/block.go
@@ -424,9 +424,9 @@
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 0c16efc..59d768c 100644
--- a/src/cmd/compile/internal/ssa/cache.go
+++ b/src/cmd/compile/internal/ssa/cache.go
@@ -29,7 +29,7 @@
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 ec02409..3540db4 100644
--- a/src/cmd/compile/internal/ssa/config.go
+++ b/src/cmd/compile/internal/ssa/config.go
@@ -126,17 +126,17 @@
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 fe31b12..20e548f 100644
--- a/src/cmd/compile/internal/ssa/copyelim_test.go
+++ b/src/cmd/compile/internal/ssa/copyelim_test.go
@@ -20,7 +20,7 @@
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 7edc414..687abc4 100644
--- a/src/cmd/compile/internal/ssa/debug.go
+++ b/src/cmd/compile/internal/ssa/debug.go
@@ -195,7 +195,7 @@
// 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 1e2a0df..8a5b364 100644
--- a/src/cmd/compile/internal/ssa/expand_calls.go
+++ b/src/cmd/compile/internal/ssa/expand_calls.go
@@ -951,7 +951,7 @@
}
// 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 c33c77f..3ab0be7 100644
--- a/src/cmd/compile/internal/ssa/export_test.go
+++ b/src/cmd/compile/internal/ssa/export_test.go
@@ -98,12 +98,12 @@
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 fc8cb3f..56690c8 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -336,7 +336,7 @@
// 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 @@
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 4639d674..1a378d4 100644
--- a/src/cmd/compile/internal/ssa/func_test.go
+++ b/src/cmd/compile/internal/ssa/func_test.go
@@ -206,7 +206,7 @@
// 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 85a414f..7a6683e 100644
--- a/src/cmd/compile/internal/ssa/html.go
+++ b/src/cmd/compile/internal/ssa/html.go
@@ -53,13 +53,13 @@
}
// 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 @@
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 325118a..8006253 100644
--- a/src/cmd/compile/internal/ssa/schedule.go
+++ b/src/cmd/compile/internal/ssa/schedule.go
@@ -36,13 +36,13 @@
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 a27002e..766598e 100644
--- a/src/cmd/compile/internal/ssa/sizeof_test.go
+++ b/src/cmd/compile/internal/ssa/sizeof_test.go
@@ -16,9 +16,9 @@
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 51a70c7..809ed6c 100644
--- a/src/cmd/compile/internal/ssa/value.go
+++ b/src/cmd/compile/internal/ssa/value.go
@@ -471,9 +471,9 @@
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 0dcf353..4043ac4 100644
--- a/src/cmd/compile/internal/ssagen/phi.go
+++ b/src/cmd/compile/internal/ssagen/phi.go
@@ -396,11 +396,11 @@
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 ae7d575..3dea733 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -1115,13 +1115,13 @@
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 @@
}
// 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 @@
}
// 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 8b36017..3a2479b 100644
--- a/src/cmd/compile/internal/syntax/branches.go
+++ b/src/cmd/compile/internal/syntax/branches.go
@@ -61,7 +61,7 @@
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 d524788..9a021a4 100644
--- a/src/cmd/compile/internal/syntax/dumper.go
+++ b/src/cmd/compile/internal/syntax/dumper.go
@@ -89,7 +89,7 @@
}
// 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 d86d77e..86d93e8 100644
--- a/src/cmd/compile/internal/syntax/printer.go
+++ b/src/cmd/compile/internal/syntax/printer.go
@@ -247,7 +247,7 @@
// 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 @@
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 807d838..700908f 100644
--- a/src/cmd/compile/internal/syntax/scanner.go
+++ b/src/cmd/compile/internal/syntax/scanner.go
@@ -50,12 +50,12 @@
}
// 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 83b102d..dd8f2b8 100644
--- a/src/cmd/compile/internal/syntax/syntax.go
+++ b/src/cmd/compile/internal/syntax/syntax.go
@@ -36,7 +36,7 @@
// 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 8ff7a60..b6d3e24 100644
--- a/src/cmd/compile/internal/test/fixedbugs_test.go
+++ b/src/cmd/compile/internal/test/fixedbugs_test.go
@@ -24,7 +24,7 @@
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 db41eb8..cb7dc70 100644
--- a/src/cmd/compile/internal/test/iface_test.go
+++ b/src/cmd/compile/internal/test/iface_test.go
@@ -13,7 +13,7 @@
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 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 @@
}
//go:noinline
-func e2int3(i interface{}) int {
+func e2int3(i any) int {
x = 7
return i.(int)
}
@@ -51,7 +51,7 @@
}
//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 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 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 @@
}
//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 492379e..d540f25 100644
--- a/src/cmd/compile/internal/test/shift_test.go
+++ b/src/cmd/compile/internal/test/shift_test.go
@@ -916,7 +916,7 @@
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 c97220e..d7aad9c 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -713,7 +713,7 @@
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 67e2e99..848720e 100644
--- a/src/cmd/compile/internal/types/fmt.go
+++ b/src/cmd/compile/internal/types/fmt.go
@@ -183,7 +183,7 @@
}
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 ba033ec..1b80659 100644
--- a/src/cmd/compile/internal/types/sizeof_test.go
+++ b/src/cmd/compile/internal/types/sizeof_test.go
@@ -16,9 +16,9 @@
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 da85929..8de589b 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -174,7 +174,7 @@
// 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 8b27d9d..77c5945 100644
--- a/src/cmd/compile/internal/types2/check.go
+++ b/src/cmd/compile/internal/types2/check.go
@@ -118,7 +118,7 @@
// 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 @@
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 44f2adc..e2f5508 100644
--- a/src/cmd/compile/internal/types2/errors.go
+++ b/src/cmd/compile/internal/types2/errors.go
@@ -56,7 +56,7 @@
// 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 d62b024..39bf405 100644
--- a/src/cmd/compile/internal/types2/expr.go
+++ b/src/cmd/compile/internal/types2/expr.go
@@ -1247,7 +1247,7 @@
// 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 df8a3e7..6cc0974 100644
--- a/src/cmd/compile/internal/types2/hilbert_test.go
+++ b/src/cmd/compile/internal/types2/hilbert_test.go
@@ -68,7 +68,7 @@
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 13b9620..092e823 100644
--- a/src/cmd/compile/internal/types2/sizeof_test.go
+++ b/src/cmd/compile/internal/types2/sizeof_test.go
@@ -15,9 +15,9 @@
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 a579c81..f778a01 100644
--- a/src/cmd/compile/internal/types2/stdlib_test.go
+++ b/src/cmd/compile/internal/types2/stdlib_test.go
@@ -460,7 +460,7 @@
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 efe9c99..47ca4d9 100644
--- a/src/cmd/compile/internal/types2/stmt.go
+++ b/src/cmd/compile/internal/types2/stmt.go
@@ -192,7 +192,7 @@
}
// 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 @@
// 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 f4f24f4..7250d82 100644
--- a/src/cmd/compile/internal/types2/unify.go
+++ b/src/cmd/compile/internal/types2/unify.go
@@ -141,7 +141,7 @@
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 765b0f7..5122850 100644
--- a/src/cmd/compile/internal/types2/version.go
+++ b/src/cmd/compile/internal/types2/version.go
@@ -58,7 +58,7 @@
// 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 122ad28..b88b817 100644
--- a/src/cmd/covdata/covdata.go
+++ b/src/cmd/covdata/covdata.go
@@ -42,14 +42,14 @@
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 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 9c9e1b8..15cfccc 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -1108,7 +1108,7 @@
// 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 @@
// 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 121c2dc..1109bf0 100644
--- a/src/cmd/dist/util.go
+++ b/src/cmd/dist/util.go
@@ -21,7 +21,7 @@
// 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 @@
}
// 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 @@
}
// 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 3998ce1..0ec4102 100644
--- a/src/cmd/go/internal/modload/import.go
+++ b/src/cmd/go/internal/modload/import.go
@@ -268,7 +268,7 @@
// 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 e0e0634..f9fd522 100644
--- a/src/cmd/internal/cov/readcovdata.go
+++ b/src/cmd/internal/cov/readcovdata.go
@@ -145,14 +145,14 @@
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) 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 6e06f13..b8956b4 100644
--- a/src/cmd/internal/dwarf/dwarf.go
+++ b/src/cmd/internal/dwarf/dwarf.go
@@ -40,8 +40,7 @@
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 @@
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 @@
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 @@
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 ad29c32..6c9907d 100644
--- a/src/cmd/internal/macho/macho.go
+++ b/src/cmd/internal/macho/macho.go
@@ -100,7 +100,7 @@
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 @@
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 670b0f3..d09aa98 100644
--- a/src/cmd/internal/obj/dwarf.go
+++ b/src/cmd/internal/obj/dwarf.go
@@ -231,7 +231,7 @@
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 @@
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 @@
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 9f3814e..85dca33 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -211,7 +211,7 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
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) 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 e0aca15..53cea8d 100644
--- a/src/cmd/internal/obj/loong64/asm.go
+++ b/src/cmd/internal/obj/loong64/asm.go
@@ -1340,7 +1340,7 @@
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 67a0780..1cfcde7 100644
--- a/src/cmd/internal/obj/pcln.go
+++ b/src/cmd/internal/obj/pcln.go
@@ -22,7 +22,7 @@
//
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
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 ab7af22..9f1acf4 100644
--- a/src/cmd/internal/obj/ppc64/asm_test.go
+++ b/src/cmd/internal/obj/ppc64/asm_test.go
@@ -439,7 +439,7 @@
}
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 69e6047..fdee114 100644
--- a/src/cmd/internal/obj/sizeof_test.go
+++ b/src/cmd/internal/obj/sizeof_test.go
@@ -16,9 +16,9 @@
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 8709c4e..32d71d0 100644
--- a/src/cmd/internal/objabi/flag.go
+++ b/src/cmd/internal/objabi/flag.go
@@ -85,7 +85,7 @@
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 @@
return nil
}
-func (c *count) Get() interface{} {
+func (c *count) Get() any {
return int(*c)
}
@@ -206,8 +206,8 @@
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 @@
//
// 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 222e712..31de34a 100644
--- a/src/cmd/link/internal/ld/dwarf.go
+++ b/src/cmd/link/internal/ld/dwarf.go
@@ -100,7 +100,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 df1fc7f..2276d39 100644
--- a/src/cmd/link/internal/ld/link.go
+++ b/src/cmd/link/internal/ld/link.go
@@ -126,7 +126,7 @@
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 d60755f..2b303cb 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 @@
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 556c77d7..f3787ff 100644
--- a/src/cmd/link/internal/ld/util.go
+++ b/src/cmd/link/internal/ld/util.go
@@ -32,7 +32,7 @@
}
// 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 @@
//
// 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 @@
//
// 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 fc98fcb..4500a7c 100644
--- a/src/cmd/link/internal/ld/xcoff.go
+++ b/src/cmd/link/internal/ld/xcoff.go
@@ -167,8 +167,7 @@
)
// 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 9434704..1c83f03 100644
--- a/src/cmd/link/internal/loadelf/ldelf.go
+++ b/src/cmd/link/internal/loadelf/ldelf.go
@@ -242,7 +242,7 @@
// 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 a612a1a..2d386c0 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -2821,7 +2821,7 @@
//
// 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 @@
}
// 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 dcb0fd9..ecd0150 100644
--- a/src/cmd/link/internal/loadmacho/ldmacho.go
+++ b/src/cmd/link/internal/loadmacho/ldmacho.go
@@ -424,7 +424,7 @@
// 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 fd116d5..8c0949e 100644
--- a/src/cmd/link/internal/loadxcoff/ldxcoff.go
+++ b/src/cmd/link/internal/loadxcoff/ldxcoff.go
@@ -42,7 +42,7 @@
// 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 c889e71..d397b84 100644
--- a/src/cmd/link/internal/sym/segment.go
+++ b/src/cmd/link/internal/sym/segment.go
@@ -52,7 +52,7 @@
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
diff --git a/src/crypto/internal/cryptotest/methods.go b/src/crypto/internal/cryptotest/methods.go
index 9105eb30..f7d48a0 100644
--- a/src/crypto/internal/cryptotest/methods.go
+++ b/src/crypto/internal/cryptotest/methods.go
@@ -19,7 +19,7 @@
// of the API even if undocumented per Hyrum's Law.
//
// ms must be a pointer to a non-nil interface.
-func NoExtraMethods(t *testing.T, ms interface{}, allowed ...string) {
+func NoExtraMethods(t *testing.T, ms any, allowed ...string) {
t.Helper()
extraMethods, err := extraMethods(ms)
if err != nil {
@@ -33,7 +33,7 @@
}
}
-func extraMethods(ip interface{}) ([]string, error) {
+func extraMethods(ip any) ([]string, error) {
v := reflect.ValueOf(ip)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Interface || v.Elem().IsNil() {
return nil, fmt.Errorf("argument must be a pointer to a non-nil interface")
diff --git a/src/crypto/internal/fips140/edwards25519/scalar_alias_test.go b/src/crypto/internal/fips140/edwards25519/scalar_alias_test.go
index 1893a7f..47831db 100644
--- a/src/crypto/internal/fips140/edwards25519/scalar_alias_test.go
+++ b/src/crypto/internal/fips140/edwards25519/scalar_alias_test.go
@@ -71,7 +71,7 @@
return x == x1 && y == y1
}
- for name, f := range map[string]interface{}{
+ for name, f := range map[string]any{
"Negate": func(v, x Scalar) bool {
return checkAliasingOneArg((*Scalar).Negate, v, x)
},
diff --git a/src/crypto/tls/fips140_test.go b/src/crypto/tls/fips140_test.go
index d3fa61d..291a19f 100644
--- a/src/crypto/tls/fips140_test.go
+++ b/src/crypto/tls/fips140_test.go
@@ -404,7 +404,7 @@
L2_I := fipsCert(t, "L2_I", fipsRSAKey(t, 1024), I_R1, fipsCertLeaf)
// client verifying server cert
- testServerCert := func(t *testing.T, desc string, pool *x509.CertPool, key interface{}, list [][]byte, ok bool) {
+ testServerCert := func(t *testing.T, desc string, pool *x509.CertPool, key any, list [][]byte, ok bool) {
clientConfig := testConfig.Clone()
clientConfig.RootCAs = pool
clientConfig.InsecureSkipVerify = false
@@ -432,7 +432,7 @@
}
// server verifying client cert
- testClientCert := func(t *testing.T, desc string, pool *x509.CertPool, key interface{}, list [][]byte, ok bool) {
+ testClientCert := func(t *testing.T, desc string, pool *x509.CertPool, key any, list [][]byte, ok bool) {
clientConfig := testConfig.Clone()
clientConfig.ServerName = "example.com"
clientConfig.Certificates = []Certificate{{Certificate: list, PrivateKey: key}}
@@ -574,11 +574,11 @@
parentOrg string
der []byte
cert *x509.Certificate
- key interface{}
+ key any
fipsOK bool
}
-func fipsCert(t *testing.T, name string, key interface{}, parent *fipsCertificate, mode int) *fipsCertificate {
+func fipsCert(t *testing.T, name string, key any, parent *fipsCertificate, mode int) *fipsCertificate {
org := name
parentOrg := ""
if i := strings.Index(org, "_"); i >= 0 {
@@ -605,7 +605,7 @@
}
var pcert *x509.Certificate
- var pkey interface{}
+ var pkey any
if parent != nil {
pcert = parent.cert
pkey = parent.key
@@ -614,7 +614,7 @@
pkey = key
}
- var pub interface{}
+ var pub any
var desc string
switch k := key.(type) {
case *rsa.PrivateKey:
diff --git a/src/encoding/gob/encoder_test.go b/src/encoding/gob/encoder_test.go
index 3ee43fb..3810685 100644
--- a/src/encoding/gob/encoder_test.go
+++ b/src/encoding/gob/encoder_test.go
@@ -1274,7 +1274,7 @@
0x12, 0xff, 0xff, 0x2, 0x2, 0x20, 0x0, 0xf8, 0x7f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0x20, 0x20,
}))
- var r interface{}
+ var r any
err := dec.Decode(r)
if err == nil {
t.Fatalf("expected an error")
diff --git a/src/go/types/errors.go b/src/go/types/errors.go
index be1ec5d..fabcbe6 100644
--- a/src/go/types/errors.go
+++ b/src/go/types/errors.go
@@ -57,7 +57,7 @@
// 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 positioner, format string, args ...interface{}) {
+func (err *error_) addf(at positioner, format string, args ...any) {
err.desc = append(err.desc, errorDesc{at, err.check.sprintf(format, args...)})
}
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index 65995d9..8b3f764 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -1198,7 +1198,7 @@
// 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/go/types/version.go b/src/go/types/version.go
index 8133110..5ba12c4 100644
--- a/src/go/types/version.go
+++ b/src/go/types/version.go
@@ -58,7 +58,7 @@
// 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 positioner, v goVersion, format string, args ...interface{}) bool {
+func (check *Checker) verifyVersionf(at positioner, v goVersion, format string, args ...any) bool {
if !check.allowVersion(v) {
check.versionErrorf(at, v, format, args...)
return false
diff --git a/src/internal/abi/funcpc.go b/src/internal/abi/funcpc.go
index e038d36..54b0735 100644
--- a/src/internal/abi/funcpc.go
+++ b/src/internal/abi/funcpc.go
@@ -19,7 +19,7 @@
// compile-time error.
//
// Implemented as a compile intrinsic.
-func FuncPCABI0(f interface{}) uintptr
+func FuncPCABI0(f any) uintptr
// FuncPCABIInternal returns the entry PC of the function f. If f is a
// direct reference of a function, it must be defined as ABIInternal.
@@ -28,4 +28,4 @@
// the behavior is undefined.
//
// Implemented as a compile intrinsic.
-func FuncPCABIInternal(f interface{}) uintptr
+func FuncPCABIInternal(f any) uintptr
diff --git a/src/internal/coverage/pods/pods.go b/src/internal/coverage/pods/pods.go
index e6180fb..15b56f8 100644
--- a/src/internal/coverage/pods/pods.go
+++ b/src/internal/coverage/pods/pods.go
@@ -192,7 +192,7 @@
return pods
}
-func warning(s string, a ...interface{}) {
+func warning(s string, a ...any) {
fmt.Fprintf(os.Stderr, "warning: ")
fmt.Fprintf(os.Stderr, s, a...)
fmt.Fprintf(os.Stderr, "\n")
diff --git a/src/internal/singleflight/singleflight_test.go b/src/internal/singleflight/singleflight_test.go
index 279e1be..0cce6a7 100644
--- a/src/internal/singleflight/singleflight_test.go
+++ b/src/internal/singleflight/singleflight_test.go
@@ -97,7 +97,7 @@
key := "key"
firstCh := make(chan struct{})
go func() {
- g.Do(key, func() (i interface{}, e error) {
+ g.Do(key, func() (i any, e error) {
firstStarted.Done()
<-firstCh
return
@@ -110,7 +110,7 @@
secondCh := make(chan struct{})
go func() {
- g.Do(key, func() (i interface{}, e error) {
+ g.Do(key, func() (i any, e error) {
// Notify that we started
secondCh <- struct{}{}
<-secondCh
@@ -120,7 +120,7 @@
<-secondCh
- resultCh := g.DoChan(key, func() (i interface{}, e error) {
+ resultCh := g.DoChan(key, func() (i any, e error) {
panic("third must not be started")
})
@@ -155,7 +155,7 @@
wg.Add(n)
for i := 0; i < n; i++ {
go func() {
- g.Do(key, func() (interface{}, error) {
+ g.Do(key, func() (any, error) {
time.Sleep(d)
return calls.Add(1), nil
})
diff --git a/src/math/big/alias_test.go b/src/math/big/alias_test.go
index 8bfb632..71b0c7c 100644
--- a/src/math/big/alias_test.go
+++ b/src/math/big/alias_test.go
@@ -179,7 +179,7 @@
}
func TestAliasing(t *testing.T) {
- for name, f := range map[string]interface{}{
+ for name, f := range map[string]any{
"Abs": func(v, x bigInt) bool {
return checkAliasingOneArg(t, (*big.Int).Abs, v.Int, x.Int)
},
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go
index 1fa850a..8509f00 100644
--- a/src/reflect/all_test.go
+++ b/src/reflect/all_test.go
@@ -8096,11 +8096,11 @@
func TestValue_Comparable(t *testing.T) {
var a int
var s []int
- var i interface{} = a
- var iNil interface{}
- var iSlice interface{} = s
- var iArrayFalse interface{} = [2]interface{}{1, map[int]int{}}
- var iArrayTrue interface{} = [2]interface{}{1, struct{ I interface{} }{1}}
+ var i any = a
+ var iNil any
+ var iSlice any = s
+ var iArrayFalse any = [2]any{1, map[int]int{}}
+ var iArrayTrue any = [2]any{1, struct{ I any }{1}}
var testcases = []struct {
value Value
comparable bool
@@ -8237,22 +8237,22 @@
false,
},
{
- ValueOf([2]struct{ I interface{} }{{1}, {1}}),
+ ValueOf([2]struct{ I any }{{1}, {1}}),
true,
false,
},
{
- ValueOf([2]struct{ I interface{} }{{[]int{}}, {1}}),
+ ValueOf([2]struct{ I any }{{[]int{}}, {1}}),
false,
false,
},
{
- ValueOf([2]interface{}{1, struct{ I int }{1}}),
+ ValueOf([2]any{1, struct{ I int }{1}}),
true,
false,
},
{
- ValueOf([2]interface{}{[1]interface{}{map[int]int{}}, struct{ I int }{1}}),
+ ValueOf([2]any{[1]any{map[int]int{}}, struct{ I int }{1}}),
false,
false,
},
@@ -8286,10 +8286,10 @@
vDeref, uDeref bool
}
-var equalI interface{} = 1
-var equalSlice interface{} = []int{1}
-var nilInterface interface{}
-var mapInterface interface{} = map[int]int{}
+var equalI any = 1
+var equalSlice any = []int{1}
+var nilInterface any
+var mapInterface any = map[int]int{}
var valueEqualTests = []ValueEqualTest{
{
@@ -8468,8 +8468,8 @@
// Value of array is non-comparable because of non-comparable elements.
ValueOf([0]map[int]int{}),
ValueOf([0]func(){}),
- ValueOf(([1]struct{ I interface{} }{{[]int{}}})),
- ValueOf(([1]interface{}{[1]interface{}{map[int]int{}}})),
+ ValueOf(([1]struct{ I any }{{[]int{}}})),
+ ValueOf(([1]any{[1]any{map[int]int{}}})),
}
for _, value := range values {
// Panic when reflect.Value.Equal using two valid non-comparable values.
diff --git a/src/reflect/type_test.go b/src/reflect/type_test.go
index fc76a4f..00344c62 100644
--- a/src/reflect/type_test.go
+++ b/src/reflect/type_test.go
@@ -12,7 +12,7 @@
func TestTypeFor(t *testing.T) {
type (
mystring string
- myiface interface{}
+ myiface any
)
testcases := []struct {
diff --git a/src/runtime/metrics_test.go b/src/runtime/metrics_test.go
index b674243..92cec75 100644
--- a/src/runtime/metrics_test.go
+++ b/src/runtime/metrics_test.go
@@ -471,7 +471,7 @@
b.ReportMetric(float64(latencies[len(latencies)*99/100]), "p99-ns")
}
-var readMetricsSink [1024]interface{}
+var readMetricsSink [1024]any
func TestReadMetricsCumulative(t *testing.T) {
// Set up the set of metrics marked cumulative.
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index b816833..adbd193 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -1627,7 +1627,7 @@
obj := new(T)
ch1, ch2 := make(chan int), make(chan int)
defer close(ch2)
- runtime.SetFinalizer(obj, func(_ interface{}) {
+ runtime.SetFinalizer(obj, func(_ any) {
close(ch1)
<-ch2
})
@@ -1829,7 +1829,7 @@
var objs []*T
for range 10000 {
obj := new(T)
- runtime.SetFinalizer(obj, func(_ interface{}) {})
+ runtime.SetFinalizer(obj, func(_ any) {})
objs = append(objs, obj)
}
objs = nil