diff options
author | Russ Cox <rsc@golang.org> | 2021-12-01 12:15:45 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-12-13 18:45:54 +0000 |
commit | 2580d0e08d5e9f979b943758d3c49877fb2324cb (patch) | |
tree | 3aafccfd81087734156a1778ce2321adf345f271 /src/os | |
parent | 083ef5462494e81ee23316245c5d65085a3f62d9 (diff) | |
download | go-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/os')
-rw-r--r-- | src/os/dir_unix.go | 2 | ||||
-rw-r--r-- | src/os/env_test.go | 2 | ||||
-rw-r--r-- | src/os/exec.go | 4 | ||||
-rw-r--r-- | src/os/exec/exec.go | 2 | ||||
-rw-r--r-- | src/os/exec/exec_test.go | 2 | ||||
-rw-r--r-- | src/os/exec_plan9.go | 4 | ||||
-rw-r--r-- | src/os/exec_posix.go | 4 | ||||
-rw-r--r-- | src/os/stat_plan9.go | 2 | ||||
-rw-r--r-- | src/os/types_plan9.go | 4 | ||||
-rw-r--r-- | src/os/types_unix.go | 2 | ||||
-rw-r--r-- | src/os/types_windows.go | 2 | ||||
-rw-r--r-- | src/os/user/lookup_unix.go | 8 |
12 files changed, 19 insertions, 19 deletions
diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go index 4eeb9ab86c..9b3871a3e8 100644 --- a/src/os/dir_unix.go +++ b/src/os/dir_unix.go @@ -27,7 +27,7 @@ const ( ) var dirBufPool = sync.Pool{ - New: func() interface{} { + New: func() any { // The buffer must be at least a block long. buf := make([]byte, blockSize) return &buf diff --git a/src/os/env_test.go b/src/os/env_test.go index 11b3b89725..f8d56ef8e0 100644 --- a/src/os/env_test.go +++ b/src/os/env_test.go @@ -66,7 +66,7 @@ func TestExpand(t *testing.T) { } } -var global interface{} +var global any func BenchmarkExpand(b *testing.B) { b.Run("noop", func(b *testing.B) { diff --git a/src/os/exec.go b/src/os/exec.go index 2beac55f89..9eb3166ecb 100644 --- a/src/os/exec.go +++ b/src/os/exec.go @@ -164,7 +164,7 @@ func (p *ProcessState) Success() bool { // Sys returns system-dependent exit information about // the process. Convert it to the appropriate underlying // type, such as syscall.WaitStatus on Unix, to access its contents. -func (p *ProcessState) Sys() interface{} { +func (p *ProcessState) Sys() any { return p.sys() } @@ -173,6 +173,6 @@ func (p *ProcessState) Sys() interface{} { // type, such as *syscall.Rusage on Unix, to access its contents. // (On Unix, *syscall.Rusage matches struct rusage as defined in the // getrusage(2) manual page.) -func (p *ProcessState) SysUsage() interface{} { +func (p *ProcessState) SysUsage() any { return p.sysUsage() } diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index 9551c22d6e..845b737e28 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -216,7 +216,7 @@ func (c *Cmd) String() string { // interfaceEqual protects against panics from doing equality tests on // two interfaces with non-comparable underlying types. -func interfaceEqual(a, b interface{}) bool { +func interfaceEqual(a, b any) bool { defer func() { recover() }() diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 81de018e09..92992a6d66 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -700,7 +700,7 @@ func TestHelperProcess(*testing.T) { cmd, args := args[0], args[1:] switch cmd { case "echo": - iargs := []interface{}{} + iargs := []any{} for _, s := range args { iargs = append(iargs, s) } diff --git a/src/os/exec_plan9.go b/src/os/exec_plan9.go index cc84f97669..69714ff798 100644 --- a/src/os/exec_plan9.go +++ b/src/os/exec_plan9.go @@ -115,11 +115,11 @@ func (p *ProcessState) success() bool { return p.status.ExitStatus() == 0 } -func (p *ProcessState) sys() interface{} { +func (p *ProcessState) sys() any { return p.status } -func (p *ProcessState) sysUsage() interface{} { +func (p *ProcessState) sysUsage() any { return p.status } diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index 07e2b36f62..d619984693 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -87,11 +87,11 @@ func (p *ProcessState) success() bool { return p.status.ExitStatus() == 0 } -func (p *ProcessState) sys() interface{} { +func (p *ProcessState) sys() any { return p.status } -func (p *ProcessState) sysUsage() interface{} { +func (p *ProcessState) sysUsage() any { return p.rusage } diff --git a/src/os/stat_plan9.go b/src/os/stat_plan9.go index 57ae6fb0bb..e20accf191 100644 --- a/src/os/stat_plan9.go +++ b/src/os/stat_plan9.go @@ -43,7 +43,7 @@ func fileInfoFromStat(d *syscall.Dir) *fileStat { } // arg is an open *File or a path string. -func dirstat(arg interface{}) (*syscall.Dir, error) { +func dirstat(arg any) (*syscall.Dir, error) { var name string var err error diff --git a/src/os/types_plan9.go b/src/os/types_plan9.go index 125da661b7..ccf4fd932e 100644 --- a/src/os/types_plan9.go +++ b/src/os/types_plan9.go @@ -15,13 +15,13 @@ type fileStat struct { size int64 mode FileMode modTime time.Time - sys interface{} + sys any } func (fs *fileStat) Size() int64 { return fs.size } func (fs *fileStat) Mode() FileMode { return fs.mode } func (fs *fileStat) ModTime() time.Time { return fs.modTime } -func (fs *fileStat) Sys() interface{} { return fs.sys } +func (fs *fileStat) Sys() any { return fs.sys } func sameFile(fs1, fs2 *fileStat) bool { a := fs1.sys.(*syscall.Dir) diff --git a/src/os/types_unix.go b/src/os/types_unix.go index 105bb78765..1b90a5a141 100644 --- a/src/os/types_unix.go +++ b/src/os/types_unix.go @@ -23,7 +23,7 @@ type fileStat struct { func (fs *fileStat) Size() int64 { return fs.size } func (fs *fileStat) Mode() FileMode { return fs.mode } func (fs *fileStat) ModTime() time.Time { return fs.modTime } -func (fs *fileStat) Sys() interface{} { return &fs.sys } +func (fs *fileStat) Sys() any { return &fs.sys } func sameFile(fs1, fs2 *fileStat) bool { return fs1.sys.Dev == fs2.sys.Dev && fs1.sys.Ino == fs2.sys.Ino diff --git a/src/os/types_windows.go b/src/os/types_windows.go index 59bf5ca381..5443dfedc8 100644 --- a/src/os/types_windows.go +++ b/src/os/types_windows.go @@ -138,7 +138,7 @@ func (fs *fileStat) ModTime() time.Time { } // Sys returns syscall.Win32FileAttributeData for file fs. -func (fs *fileStat) Sys() interface{} { +func (fs *fileStat) Sys() any { return &syscall.Win32FileAttributeData{ FileAttributes: fs.FileAttributes, CreationTime: fs.CreationTime, diff --git a/src/os/user/lookup_unix.go b/src/os/user/lookup_unix.go index e25323fbad..058dab1fb5 100644 --- a/src/os/user/lookup_unix.go +++ b/src/os/user/lookup_unix.go @@ -19,7 +19,7 @@ import ( const userFile = "/etc/passwd" // lineFunc returns a value, an error, or (nil, nil) to skip the row. -type lineFunc func(line []byte) (v interface{}, err error) +type lineFunc func(line []byte) (v any, err error) // readColonFile parses r as an /etc/group or /etc/passwd style file, running // fn for each row. readColonFile returns a value, an error, or (nil, nil) if @@ -27,7 +27,7 @@ type lineFunc func(line []byte) (v interface{}, err error) // // readCols is the minimum number of colon-separated fields that will be passed // to fn; in a long line additional fields may be silently discarded. -func readColonFile(r io.Reader, fn lineFunc, readCols int) (v interface{}, err error) { +func readColonFile(r io.Reader, fn lineFunc, readCols int) (v any, err error) { rd := bufio.NewReader(r) // Read the file line-by-line. @@ -98,7 +98,7 @@ func matchGroupIndexValue(value string, idx int) lineFunc { leadColon = ":" } substr := []byte(leadColon + value + ":") - return func(line []byte) (v interface{}, err error) { + return func(line []byte) (v any, err error) { if !bytes.Contains(line, substr) || bytes.Count(line, colon) < 3 { return } @@ -145,7 +145,7 @@ func matchUserIndexValue(value string, idx int) lineFunc { leadColon = ":" } substr := []byte(leadColon + value + ":") - return func(line []byte) (v interface{}, err error) { + return func(line []byte) (v any, err error) { if !bytes.Contains(line, substr) || bytes.Count(line, colon) < 6 { return } |