Skip to content

Commit 6016188

Browse files
committed
cmd: apply modernizers
Apply modernizers to all the files in the x/tools/cmd tree. Also suppress most warnings. Change-Id: I6cd80200f423e79971cedbc64cd731300e65c834 Reviewed-on: https://go-review.googlesource.com/c/tools/+/641355 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent f7fb515 commit 6016188

File tree

19 files changed

+52
-56
lines changed

19 files changed

+52
-56
lines changed

cmd/benchcmp/benchcmp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func main() {
133133
}
134134
}
135135

136-
func fatal(msg interface{}) {
136+
func fatal(msg any) {
137137
fmt.Fprintln(os.Stderr, msg)
138138
os.Exit(1)
139139
}

cmd/bundle/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ func testBundle(t *testing.T, x packagestest.Exporter) {
2727
e := packagestest.Export(t, x, []packagestest.Module{
2828
{
2929
Name: "initial",
30-
Files: map[string]interface{}{
30+
Files: map[string]any{
3131
"a.go": load("testdata/src/initial/a.go"),
3232
"b.go": load("testdata/src/initial/b.go"),
3333
"c.go": load("testdata/src/initial/c.go"),
3434
},
3535
},
3636
{
3737
Name: "domain.name/importdecl",
38-
Files: map[string]interface{}{
38+
Files: map[string]any{
3939
"p.go": load("testdata/src/domain.name/importdecl/p.go"),
4040
},
4141
},

cmd/godex/godex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func main() {
8484
}
8585
}
8686

87-
func logf(format string, args ...interface{}) {
87+
func logf(format string, args ...any) {
8888
if *verbose {
8989
fmt.Fprintf(os.Stderr, format, args...)
9090
}

cmd/godex/print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (p *printer) print(s string) {
4848
}
4949
}
5050

51-
func (p *printer) printf(format string, args ...interface{}) {
51+
func (p *printer) printf(format string, args ...any) {
5252
p.print(fmt.Sprintf(format, args...))
5353
}
5454

cmd/godex/writetype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (p *printer) writeTypeInternal(this *types.Package, typ types.Type, visited
111111
//
112112
n := t.NumMethods()
113113
if n == 0 {
114-
p.print("interface{}")
114+
p.print("any")
115115
return
116116
}
117117

cmd/godoc/godoc_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ func serverAddress(t *testing.T) string {
7171
return ln.Addr().String()
7272
}
7373

74-
func waitForServerReady(t *testing.T, ctx context.Context, cmd *exec.Cmd, addr string) {
74+
func waitForServerReady(t *testing.T, ctx context.Context, addr string) {
7575
waitForServer(t, ctx,
7676
fmt.Sprintf("http://%v/", addr),
7777
"Go Documentation Server",
7878
false)
7979
}
8080

81-
func waitForSearchReady(t *testing.T, ctx context.Context, cmd *exec.Cmd, addr string) {
81+
func waitForSearchReady(t *testing.T, ctx context.Context, _ *exec.Cmd, addr string) {
8282
waitForServer(t, ctx,
8383
fmt.Sprintf("http://%v/search?q=FALLTHROUGH", addr),
8484
"The list of tokens.",
@@ -208,15 +208,15 @@ func testWeb(t *testing.T, x packagestest.Exporter, bin string, withIndex bool)
208208
e := packagestest.Export(t, x, []packagestest.Module{
209209
{
210210
Name: "godoc.test/repo1",
211-
Files: map[string]interface{}{
211+
Files: map[string]any{
212212
"a/a.go": `// Package a is a package in godoc.test/repo1.
213213
package a; import _ "godoc.test/repo2/a"; const Name = "repo1a"`,
214214
"b/b.go": `package b; const Name = "repo1b"`,
215215
},
216216
},
217217
{
218218
Name: "godoc.test/repo2",
219-
Files: map[string]interface{}{
219+
Files: map[string]any{
220220
"a/a.go": `package a; const Name = "repo2a"`,
221221
"b/b.go": `package b; const Name = "repo2b"`,
222222
},
@@ -261,7 +261,7 @@ package a; import _ "godoc.test/repo2/a"; const Name = "repo1a"`,
261261
if withIndex {
262262
waitForSearchReady(t, ctx, cmd, addr)
263263
} else {
264-
waitForServerReady(t, ctx, cmd, addr)
264+
waitForServerReady(t, ctx, addr)
265265
waitUntilScanComplete(t, ctx, addr)
266266
}
267267

cmd/gotype/gotype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func report(err error) {
185185
}
186186

187187
// parse may be called concurrently
188-
func parse(filename string, src interface{}) (*ast.File, error) {
188+
func parse(filename string, src any) (*ast.File, error) {
189189
if *verbose {
190190
fmt.Println(filename)
191191
}

cmd/goyacc/yacc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import (
5252
"go/format"
5353
"math"
5454
"os"
55+
"slices"
5556
"strconv"
5657
"strings"
5758
"unicode"
@@ -2323,7 +2324,7 @@ func wrstate(i int) {
23232324
var pp, qq int
23242325

23252326
if len(errors) > 0 {
2326-
actions := append([]int(nil), temp1...)
2327+
actions := slices.Clone(temp1)
23272328
defaultAction := ERRCODE
23282329
if lastred != 0 {
23292330
defaultAction = -lastred
@@ -3176,7 +3177,7 @@ func create(s string) *bufio.Writer {
31763177
}
31773178

31783179
// write out error comment
3179-
func lerrorf(lineno int, s string, v ...interface{}) {
3180+
func lerrorf(lineno int, s string, v ...any) {
31803181
nerrors++
31813182
fmt.Fprintf(stderr, s, v...)
31823183
fmt.Fprintf(stderr, ": %v:%v\n", infile, lineno)
@@ -3186,7 +3187,7 @@ func lerrorf(lineno int, s string, v ...interface{}) {
31863187
}
31873188
}
31883189

3189-
func errorf(s string, v ...interface{}) {
3190+
func errorf(s string, v ...any) {
31903191
lerrorf(lineno, s, v...)
31913192
}
31923193

cmd/signature-fuzzer/fuzz-driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var selbadfcnflag = flag.Int("badfcnidx", 0, "[Testing only] select index of bad
5959
var goimpflag = flag.Bool("goimports", false, "Run 'goimports' on generated code.")
6060
var randctlflag = flag.Int("randctl", generator.RandCtlChecks|generator.RandCtlPanic, "Wraprand control flag")
6161

62-
func verb(vlevel int, s string, a ...interface{}) {
62+
func verb(vlevel int, s string, a ...any) {
6363
if *verbflag >= vlevel {
6464
fmt.Printf(s, a...)
6565
fmt.Printf("\n")

cmd/signature-fuzzer/fuzz-runner/rnr_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"golang.org/x/tools/internal/testenv"
1717
)
1818

19-
func canRace(t *testing.T) bool {
19+
func canRace() bool {
2020
_, err := exec.Command("go", "run", "-race", "./testdata/himom.go").CombinedOutput()
2121
return err == nil
2222
}
@@ -70,7 +70,7 @@ func testRace(t *testing.T, binaryPath string) {
7070
// For this test to work, the current test platform has to support the
7171
// race detector. Check to see if that is the case by running a very
7272
// simple Go program through it.
73-
if !canRace(t) {
73+
if !canRace() {
7474
t.Skip("current platform does not appear to support the race detector")
7575
}
7676

0 commit comments

Comments
 (0)