aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-12-01 12:15:45 -0500
committerRuss Cox <rsc@golang.org>2021-12-13 18:45:54 +0000
commit2580d0e08d5e9f979b943758d3c49877fb2324cb (patch)
tree3aafccfd81087734156a1778ce2321adf345f271 /src/debug
parent083ef5462494e81ee23316245c5d65085a3f62d9 (diff)
downloadgo-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.gz
go-2580d0e08d5e9f979b943758d3c49877fb2324cb.zip
all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/dwarf/entry.go6
-rw-r--r--src/debug/dwarf/entry_test.go2
-rw-r--r--src/debug/elf/elf_test.go2
-rw-r--r--src/debug/elf/file.go2
-rw-r--r--src/debug/gosym/symtab.go2
-rw-r--r--src/debug/macho/file.go2
-rw-r--r--src/debug/macho/file_test.go12
-rw-r--r--src/debug/pe/file.go6
-rw-r--r--src/debug/pe/file_test.go4
-rw-r--r--src/debug/plan9obj/file.go2
10 files changed, 20 insertions, 20 deletions
diff --git a/src/debug/dwarf/entry.go b/src/debug/dwarf/entry.go
index 25a3b5beec..cbdc838a12 100644
--- a/src/debug/dwarf/entry.go
+++ b/src/debug/dwarf/entry.go
@@ -261,7 +261,7 @@ type Entry struct {
// ClassUnknown.
type Field struct {
Attr Attr
- Val interface{}
+ Val any
Class Class
}
@@ -382,7 +382,7 @@ func (i Class) GoString() string {
// the check that the value has the expected dynamic type, as in:
// v, ok := e.Val(AttrSibling).(int64)
//
-func (e *Entry) Val(a Attr) interface{} {
+func (e *Entry) Val(a Attr) any {
if f := e.AttrField(a); f != nil {
return f.Val
}
@@ -501,7 +501,7 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
fmt = format(b.uint())
e.Field[i].Class = formToClass(fmt, a.field[i].attr, vers, b)
}
- var val interface{}
+ var val any
switch fmt {
default:
b.error("unknown entry attr format 0x" + strconv.FormatInt(int64(fmt), 16))
diff --git a/src/debug/dwarf/entry_test.go b/src/debug/dwarf/entry_test.go
index 1f41d742ea..8c6ca7259e 100644
--- a/src/debug/dwarf/entry_test.go
+++ b/src/debug/dwarf/entry_test.go
@@ -277,7 +277,7 @@ func TestUnitIteration(t *testing.T) {
for _, file := range files {
t.Run(file, func(t *testing.T) {
d := elfData(t, file)
- var units [2][]interface{}
+ var units [2][]any
for method := range units {
for r := d.Reader(); ; {
ent, err := r.Next()
diff --git a/src/debug/elf/elf_test.go b/src/debug/elf/elf_test.go
index f8985a8992..a61b491090 100644
--- a/src/debug/elf/elf_test.go
+++ b/src/debug/elf/elf_test.go
@@ -10,7 +10,7 @@ import (
)
type nameTest struct {
- val interface{}
+ val any
str string
}
diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go
index e265796ddc..eefcaab8d6 100644
--- a/src/debug/elf/file.go
+++ b/src/debug/elf/file.go
@@ -185,7 +185,7 @@ type Symbol struct {
type FormatError struct {
off int64
msg string
- val interface{}
+ val any
}
func (e *FormatError) Error() string {
diff --git a/src/debug/gosym/symtab.go b/src/debug/gosym/symtab.go
index 72490dca8a..4e63f1cdf7 100644
--- a/src/debug/gosym/symtab.go
+++ b/src/debug/gosym/symtab.go
@@ -751,7 +751,7 @@ func (e *UnknownLineError) Error() string {
type DecodingError struct {
off int
msg string
- val interface{}
+ val any
}
func (e *DecodingError) Error() string {
diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go
index cdc500e476..b57dba8496 100644
--- a/src/debug/macho/file.go
+++ b/src/debug/macho/file.go
@@ -184,7 +184,7 @@ type Symbol struct {
type FormatError struct {
off int64
msg string
- val interface{}
+ val any
}
func (e *FormatError) Error() string {
diff --git a/src/debug/macho/file_test.go b/src/debug/macho/file_test.go
index 9beeb80dd2..313c376c54 100644
--- a/src/debug/macho/file_test.go
+++ b/src/debug/macho/file_test.go
@@ -15,7 +15,7 @@ import (
type fileTest struct {
file string
hdr FileHeader
- loads []interface{}
+ loads []any
sections []*SectionHeader
relocations map[string][]Reloc
}
@@ -24,7 +24,7 @@ var fileTests = []fileTest{
{
"testdata/gcc-386-darwin-exec.base64",
FileHeader{0xfeedface, Cpu386, 0x3, 0x2, 0xc, 0x3c0, 0x85},
- []interface{}{
+ []any{
&SegmentHeader{LoadCmdSegment, 0x38, "__PAGEZERO", 0x0, 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
&SegmentHeader{LoadCmdSegment, 0xc0, "__TEXT", 0x1000, 0x1000, 0x0, 0x1000, 0x7, 0x5, 0x2, 0x0},
&SegmentHeader{LoadCmdSegment, 0xc0, "__DATA", 0x2000, 0x1000, 0x1000, 0x1000, 0x7, 0x3, 0x2, 0x0},
@@ -50,7 +50,7 @@ var fileTests = []fileTest{
{
"testdata/gcc-amd64-darwin-exec.base64",
FileHeader{0xfeedfacf, CpuAmd64, 0x80000003, 0x2, 0xb, 0x568, 0x85},
- []interface{}{
+ []any{
&SegmentHeader{LoadCmdSegment64, 0x48, "__PAGEZERO", 0x0, 0x100000000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
&SegmentHeader{LoadCmdSegment64, 0x1d8, "__TEXT", 0x100000000, 0x1000, 0x0, 0x1000, 0x7, 0x5, 0x5, 0x0},
&SegmentHeader{LoadCmdSegment64, 0x138, "__DATA", 0x100001000, 0x1000, 0x1000, 0x1000, 0x7, 0x3, 0x3, 0x0},
@@ -78,7 +78,7 @@ var fileTests = []fileTest{
{
"testdata/gcc-amd64-darwin-exec-debug.base64",
FileHeader{0xfeedfacf, CpuAmd64, 0x80000003, 0xa, 0x4, 0x5a0, 0},
- []interface{}{
+ []any{
nil, // LC_UUID
&SegmentHeader{LoadCmdSegment64, 0x1d8, "__TEXT", 0x100000000, 0x1000, 0x0, 0x0, 0x7, 0x5, 0x5, 0x0},
&SegmentHeader{LoadCmdSegment64, 0x138, "__DATA", 0x100001000, 0x1000, 0x0, 0x0, 0x7, 0x3, 0x3, 0x0},
@@ -106,7 +106,7 @@ var fileTests = []fileTest{
{
"testdata/clang-386-darwin-exec-with-rpath.base64",
FileHeader{0xfeedface, Cpu386, 0x3, 0x2, 0x10, 0x42c, 0x1200085},
- []interface{}{
+ []any{
nil, // LC_SEGMENT
nil, // LC_SEGMENT
nil, // LC_SEGMENT
@@ -130,7 +130,7 @@ var fileTests = []fileTest{
{
"testdata/clang-amd64-darwin-exec-with-rpath.base64",
FileHeader{0xfeedfacf, CpuAmd64, 0x80000003, 0x2, 0x10, 0x4c8, 0x200085},
- []interface{}{
+ []any{
nil, // LC_SEGMENT
nil, // LC_SEGMENT
nil, // LC_SEGMENT
diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go
index ab00a48f5c..aa0955a133 100644
--- a/src/debug/pe/file.go
+++ b/src/debug/pe/file.go
@@ -22,7 +22,7 @@ const seekStart = 0
// A File represents an open PE file.
type File struct {
FileHeader
- OptionalHeader interface{} // of type *OptionalHeader32 or *OptionalHeader64
+ OptionalHeader any // of type *OptionalHeader32 or *OptionalHeader64
Sections []*Section
Symbols []*Symbol // COFF symbols with auxiliary symbol records removed
COFFSymbols []COFFSymbol // all COFF symbols (including auxiliary symbol records)
@@ -452,7 +452,7 @@ func (e *FormatError) Error() string {
// and its size as seen in the file header.
// It parses the given size of bytes and returns optional header. It infers whether the
// bytes being parsed refer to 32 bit or 64 bit version of optional header.
-func readOptionalHeader(r io.ReadSeeker, sz uint16) (interface{}, error) {
+func readOptionalHeader(r io.ReadSeeker, sz uint16) (any, error) {
// If optional header size is 0, return empty optional header.
if sz == 0 {
return nil, nil
@@ -473,7 +473,7 @@ func readOptionalHeader(r io.ReadSeeker, sz uint16) (interface{}, error) {
// read reads from io.ReadSeeke, r, into data.
var err error
- read := func(data interface{}) bool {
+ read := func(data any) bool {
err = binary.Read(r, binary.LittleEndian, data)
return err == nil
}
diff --git a/src/debug/pe/file_test.go b/src/debug/pe/file_test.go
index 8964b4f847..5368e08ad7 100644
--- a/src/debug/pe/file_test.go
+++ b/src/debug/pe/file_test.go
@@ -22,7 +22,7 @@ import (
type fileTest struct {
file string
hdr FileHeader
- opthdr interface{}
+ opthdr any
sections []*SectionHeader
symbols []*Symbol
hasNoDwarfInfo bool
@@ -250,7 +250,7 @@ var fileTests = []fileTest{
},
}
-func isOptHdrEq(a, b interface{}) bool {
+func isOptHdrEq(a, b any) bool {
switch va := a.(type) {
case *OptionalHeader32:
vb, ok := b.(*OptionalHeader32)
diff --git a/src/debug/plan9obj/file.go b/src/debug/plan9obj/file.go
index c054635148..0c33fa10bb 100644
--- a/src/debug/plan9obj/file.go
+++ b/src/debug/plan9obj/file.go
@@ -82,7 +82,7 @@ type Sym struct {
type formatError struct {
off int
msg string
- val interface{}
+ val any
}
func (e *formatError) Error() string {