]> Cypherpunks repositories - gostls13.git/commit
go/printer: canonicalize //go:build and // +build lines while formatting
authorRuss Cox <rsc@golang.org>
Fri, 26 Jun 2020 20:22:35 +0000 (16:22 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 20 Feb 2021 03:54:46 +0000 (03:54 +0000)
commit9fd6cc105db89107bf163d2f0c1f8f55e442ec4d
treeebee31efffc621afc6e335ef3bb6e762726395cf
parent5b76343a1040571e3d2249168a00a4dc814e920a
go/printer: canonicalize //go:build and // +build lines while formatting

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Gofmt and any other go/printer-using program will now:

 - move //go:build and //+build lines to the appropriate file location
 - if there's no //go:build line, add one derived from the // +build lines
 - if there is a //go:build line, recompute and replace any // +build lines
   to match what the //go:build line says

For Go 1.17.

Change-Id: Ide5cc3b4a07507ba9ed6f8b0de846e840876f49f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240608
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
19 files changed:
src/go/build/deps_test.go
src/go/format/format_test.go
src/go/printer/gobuild.go [new file with mode: 0644]
src/go/printer/printer.go
src/go/printer/printer_test.go
src/go/printer/testdata/gobuild1.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild1.input [new file with mode: 0644]
src/go/printer/testdata/gobuild2.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild2.input [new file with mode: 0644]
src/go/printer/testdata/gobuild3.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild3.input [new file with mode: 0644]
src/go/printer/testdata/gobuild4.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild4.input [new file with mode: 0644]
src/go/printer/testdata/gobuild5.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild5.input [new file with mode: 0644]
src/go/printer/testdata/gobuild6.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild6.input [new file with mode: 0644]
src/go/printer/testdata/gobuild7.golden [new file with mode: 0644]
src/go/printer/testdata/gobuild7.input [new file with mode: 0644]