From b369640312a987c316c1fe1e327afea2516861ca Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 19 Feb 2021 17:19:19 -0500 Subject: [PATCH] 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 Reviewed-by: Robert Griesemer Trust: Robert Griesemer Trust: Russ Cox TryBot-Result: Go Bot Run-TryBot: Russ Cox --- cmd/bundle/main.go | 1 + cmd/bundle/testdata/out.golden | 1 + internal/lsp/command/command_gen.go | 1 + internal/lsp/command/gen/gen.go | 1 + internal/lsp/command/generate.go | 5 +++-- refactor/eg/testdata/A.template | 2 -- refactor/eg/testdata/A1.go | 2 -- refactor/eg/testdata/A1.golden | 2 -- refactor/eg/testdata/A2.go | 2 -- refactor/eg/testdata/A2.golden | 2 -- refactor/eg/testdata/B1.go | 2 -- refactor/eg/testdata/B1.golden | 2 -- refactor/eg/testdata/C1.go | 2 -- refactor/eg/testdata/C1.golden | 2 -- refactor/eg/testdata/D1.go | 2 -- refactor/eg/testdata/D1.golden | 2 -- refactor/eg/testdata/E1.go | 2 -- refactor/eg/testdata/E1.golden | 2 -- refactor/eg/testdata/F.template | 4 ++-- refactor/eg/testdata/F1.go | 2 -- refactor/eg/testdata/F1.golden | 2 -- refactor/eg/testdata/G.template | 1 - refactor/eg/testdata/G1.go | 2 -- refactor/eg/testdata/G1.golden | 2 -- refactor/eg/testdata/H1.go | 2 -- refactor/eg/testdata/H1.golden | 2 -- refactor/eg/testdata/I.template | 2 -- refactor/eg/testdata/I1.go | 2 -- refactor/eg/testdata/I1.golden | 2 -- refactor/eg/testdata/J.template | 2 -- refactor/eg/testdata/J1.go | 2 -- refactor/eg/testdata/J1.golden | 2 -- 32 files changed, 9 insertions(+), 55 deletions(-) diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go index 8e5ad2cd6..fd8b0e5a9 100644 --- a/cmd/bundle/main.go +++ b/cmd/bundle/main.go @@ -228,6 +228,7 @@ func bundle(src, dst, dstpkg, prefix, buildTags string) ([]byte, error) { 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 ed18e3d74..a8f0cfeb2 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 aca505cd8..1871c9dfa 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 a4bc486c1..3934f1adb 100644 --- a/internal/lsp/command/gen/gen.go +++ b/internal/lsp/command/gen/gen.go @@ -22,6 +22,7 @@ const src = `// Copyright 2021 The Go Authors. All rights reserved. // 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 49d72b542..14628c733 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 @@ import ( "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 f6119618b..6a23f12f6 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 9e65eb36a..c64fd800b 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 7eb2934f6..a8aeb0689 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 3ae29ad77..2fab79040 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 b6e3a6d7a..0e4ca447b 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 8b5254634..1e09c905d 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 4d4da2185..b2ed30b72 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 523b3885d..fb565a358 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 ae7759d79..d3b0b7118 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 ae0a80605..03a434c87 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 293265287..88d4a9e51 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 3ea1793f9..54054c812 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 796364f2d..ec10b41e5 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 21e1bd2a4..df73beb28 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 2258abda5..da9c9de1b 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 5ffda6985..ea5d0cde3 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 69d84fe9f..ab368ce46 100644 --- a/refactor/eg/testdata/G.template +++ b/refactor/eg/testdata/G.template @@ -7,4 +7,3 @@ import ( 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 07aaff916..0fb9ab95b 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 c93c53fc3..ba3704c42 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 ef4291c18..e151ac877 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 a1e596126..da2658a66 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 d03e77482..b8e8f939b 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 d1762ebb3..ef3fe8bef 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 f33b3e106..d0246aeb8 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 6f82cdfe8..b3b1f1872 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 2fbeee801..532ca13e6 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 bb2f11c60..911ef8741 100644 --- a/refactor/eg/testdata/J1.golden +++ b/refactor/eg/testdata/J1.golden @@ -1,5 +1,3 @@ -// +build ignore - package I1 import "fmt"