all: fmt tests with new gofmt
Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild
The Go 1.17 gofmt will insert the extra //go:build lines.
The older gofmts will not remove them.
Get ahead of the game by adding them now.
(Keeps x/tools tests passing on go repo trybots.)
Change-Id: Ifdb4af93f6cc38a9aa616516e923384b7312e991
Reviewed-on: https://go-review.googlesource.com/c/tools/+/294413
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go
index 8e5ad2c..fd8b0e5 100644
--- a/cmd/bundle/main.go
+++ b/cmd/bundle/main.go
@@ -228,6 +228,7 @@
var out bytes.Buffer
if buildTags != "" {
+ fmt.Fprintf(&out, "//go:build %s\n", buildTags)
fmt.Fprintf(&out, "// +build %s\n\n", buildTags)
}
diff --git a/cmd/bundle/testdata/out.golden b/cmd/bundle/testdata/out.golden
index ed18e3d..a8f0cfe 100644
--- a/cmd/bundle/testdata/out.golden
+++ b/cmd/bundle/testdata/out.golden
@@ -1,3 +1,4 @@
+//go:build tag
// +build tag
// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT.
diff --git a/internal/lsp/command/command_gen.go b/internal/lsp/command/command_gen.go
index aca505c..1871c9d 100644
--- a/internal/lsp/command/command_gen.go
+++ b/internal/lsp/command/command_gen.go
@@ -4,6 +4,7 @@
// Don't include this file during code generation, or it will break the build
// if existing interface methods have been modified.
+//go:build !generate
// +build !generate
package command
diff --git a/internal/lsp/command/gen/gen.go b/internal/lsp/command/gen/gen.go
index a4bc486..3934f1a 100644
--- a/internal/lsp/command/gen/gen.go
+++ b/internal/lsp/command/gen/gen.go
@@ -22,6 +22,7 @@
// Don't include this file during code generation, or it will break the build
// if existing interface methods have been modified.
+//go:build !generate
// +build !generate
package command
diff --git a/internal/lsp/command/generate.go b/internal/lsp/command/generate.go
index 49d72b5..14628c7 100644
--- a/internal/lsp/command/generate.go
+++ b/internal/lsp/command/generate.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build ignore
// +build ignore
package main
@@ -11,11 +12,11 @@
"io/ioutil"
"os"
- "golang.org/x/tools/internal/lsp/command/generate"
+ "golang.org/x/tools/internal/lsp/command/gen"
)
func main() {
- content, err := generate.Generate()
+ content, err := gen.Generate()
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
diff --git a/refactor/eg/testdata/A.template b/refactor/eg/testdata/A.template
index f611961..6a23f12 100644
--- a/refactor/eg/testdata/A.template
+++ b/refactor/eg/testdata/A.template
@@ -1,5 +1,3 @@
-// +build ignore
-
package template
// Basic test of type-aware expression refactoring.
diff --git a/refactor/eg/testdata/A1.go b/refactor/eg/testdata/A1.go
index 9e65eb3..c64fd80 100644
--- a/refactor/eg/testdata/A1.go
+++ b/refactor/eg/testdata/A1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package A1
import (
diff --git a/refactor/eg/testdata/A1.golden b/refactor/eg/testdata/A1.golden
index 7eb2934..a8aeb06 100644
--- a/refactor/eg/testdata/A1.golden
+++ b/refactor/eg/testdata/A1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package A1
import (
diff --git a/refactor/eg/testdata/A2.go b/refactor/eg/testdata/A2.go
index 3ae29ad..2fab790 100644
--- a/refactor/eg/testdata/A2.go
+++ b/refactor/eg/testdata/A2.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package A2
// This refactoring causes addition of "errors" import.
diff --git a/refactor/eg/testdata/A2.golden b/refactor/eg/testdata/A2.golden
index b6e3a6d..0e4ca44 100644
--- a/refactor/eg/testdata/A2.golden
+++ b/refactor/eg/testdata/A2.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package A2
// This refactoring causes addition of "errors" import.
diff --git a/refactor/eg/testdata/B1.go b/refactor/eg/testdata/B1.go
index 8b52546..1e09c90 100644
--- a/refactor/eg/testdata/B1.go
+++ b/refactor/eg/testdata/B1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package B1
import "time"
diff --git a/refactor/eg/testdata/B1.golden b/refactor/eg/testdata/B1.golden
index 4d4da21..b2ed30b 100644
--- a/refactor/eg/testdata/B1.golden
+++ b/refactor/eg/testdata/B1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package B1
import "time"
diff --git a/refactor/eg/testdata/C1.go b/refactor/eg/testdata/C1.go
index 523b388..fb565a3 100644
--- a/refactor/eg/testdata/C1.go
+++ b/refactor/eg/testdata/C1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package C1
import "strings"
diff --git a/refactor/eg/testdata/C1.golden b/refactor/eg/testdata/C1.golden
index ae7759d..d3b0b71 100644
--- a/refactor/eg/testdata/C1.golden
+++ b/refactor/eg/testdata/C1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package C1
import "strings"
diff --git a/refactor/eg/testdata/D1.go b/refactor/eg/testdata/D1.go
index ae0a806..03a434c 100644
--- a/refactor/eg/testdata/D1.go
+++ b/refactor/eg/testdata/D1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package D1
import "fmt"
diff --git a/refactor/eg/testdata/D1.golden b/refactor/eg/testdata/D1.golden
index 2932652..88d4a9e 100644
--- a/refactor/eg/testdata/D1.golden
+++ b/refactor/eg/testdata/D1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package D1
import "fmt"
diff --git a/refactor/eg/testdata/E1.go b/refactor/eg/testdata/E1.go
index 3ea1793..54054c8 100644
--- a/refactor/eg/testdata/E1.go
+++ b/refactor/eg/testdata/E1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package E1
import "log"
diff --git a/refactor/eg/testdata/E1.golden b/refactor/eg/testdata/E1.golden
index 796364f..ec10b41 100644
--- a/refactor/eg/testdata/E1.golden
+++ b/refactor/eg/testdata/E1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package E1
import (
diff --git a/refactor/eg/testdata/F.template b/refactor/eg/testdata/F.template
index 21e1bd2..df73beb 100644
--- a/refactor/eg/testdata/F.template
+++ b/refactor/eg/testdata/F.template
@@ -1,8 +1,8 @@
package templates
-// Test
+// Test
import "sync"
func before(s sync.RWMutex) { s.Lock() }
-func after(s sync.RWMutex) { s.RLock() }
\ No newline at end of file
+func after(s sync.RWMutex) { s.RLock() }
diff --git a/refactor/eg/testdata/F1.go b/refactor/eg/testdata/F1.go
index 2258abd..da9c9de 100644
--- a/refactor/eg/testdata/F1.go
+++ b/refactor/eg/testdata/F1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package F1
import "sync"
diff --git a/refactor/eg/testdata/F1.golden b/refactor/eg/testdata/F1.golden
index 5ffda69..ea5d0cd 100644
--- a/refactor/eg/testdata/F1.golden
+++ b/refactor/eg/testdata/F1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package F1
import "sync"
diff --git a/refactor/eg/testdata/G.template b/refactor/eg/testdata/G.template
index 69d84fe..ab368ce 100644
--- a/refactor/eg/testdata/G.template
+++ b/refactor/eg/testdata/G.template
@@ -7,4 +7,3 @@
func before(from, to token.Pos) ast.BadExpr { return ast.BadExpr{From: from, To: to} }
func after(from, to token.Pos) ast.BadExpr { return ast.BadExpr{from, to} }
-
\ No newline at end of file
diff --git a/refactor/eg/testdata/G1.go b/refactor/eg/testdata/G1.go
index 07aaff9..0fb9ab9 100644
--- a/refactor/eg/testdata/G1.go
+++ b/refactor/eg/testdata/G1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package G1
import "go/ast"
diff --git a/refactor/eg/testdata/G1.golden b/refactor/eg/testdata/G1.golden
index c93c53f..ba3704c 100644
--- a/refactor/eg/testdata/G1.golden
+++ b/refactor/eg/testdata/G1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package G1
import "go/ast"
diff --git a/refactor/eg/testdata/H1.go b/refactor/eg/testdata/H1.go
index ef4291c..e151ac8 100644
--- a/refactor/eg/testdata/H1.go
+++ b/refactor/eg/testdata/H1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package H1
import "go/ast"
diff --git a/refactor/eg/testdata/H1.golden b/refactor/eg/testdata/H1.golden
index a1e5961..da2658a 100644
--- a/refactor/eg/testdata/H1.golden
+++ b/refactor/eg/testdata/H1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package H1
import "go/ast"
diff --git a/refactor/eg/testdata/I.template b/refactor/eg/testdata/I.template
index d03e774..b8e8f93 100644
--- a/refactor/eg/testdata/I.template
+++ b/refactor/eg/testdata/I.template
@@ -1,5 +1,3 @@
-// +build ignore
-
package templates
import (
diff --git a/refactor/eg/testdata/I1.go b/refactor/eg/testdata/I1.go
index d1762eb..ef3fe8b 100644
--- a/refactor/eg/testdata/I1.go
+++ b/refactor/eg/testdata/I1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package I1
import "fmt"
diff --git a/refactor/eg/testdata/I1.golden b/refactor/eg/testdata/I1.golden
index f33b3e1..d0246ae 100644
--- a/refactor/eg/testdata/I1.golden
+++ b/refactor/eg/testdata/I1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package I1
import (
diff --git a/refactor/eg/testdata/J.template b/refactor/eg/testdata/J.template
index 6f82cdf..b3b1f18 100644
--- a/refactor/eg/testdata/J.template
+++ b/refactor/eg/testdata/J.template
@@ -1,5 +1,3 @@
-// +build ignore
-
package templates
import ()
diff --git a/refactor/eg/testdata/J1.go b/refactor/eg/testdata/J1.go
index 2fbeee8..532ca13 100644
--- a/refactor/eg/testdata/J1.go
+++ b/refactor/eg/testdata/J1.go
@@ -1,5 +1,3 @@
-// +build ignore
-
package I1
import "fmt"
diff --git a/refactor/eg/testdata/J1.golden b/refactor/eg/testdata/J1.golden
index bb2f11c..911ef87 100644
--- a/refactor/eg/testdata/J1.golden
+++ b/refactor/eg/testdata/J1.golden
@@ -1,5 +1,3 @@
-// +build ignore
-
package I1
import "fmt"