From df35ade067f22ef1f3aad3c2f3576997ff9646b4 Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Tue, 8 Jun 2021 20:34:16 -0400 Subject: [PATCH] doc/go1.17: document //go:build lines In 1.17, //go:build lines are fully supported. This entails changes to the go command, vet, and gofmt. Document all of them. I'm not Russ, but this is a significant change, it slipped under the radar, and we're trying to get the release out. So here's what I got. I wasn't sure where to put the go command change. On the one hand, it's pretty significant. On the other, it certainly affects fewer people than lazy loading. So it probably shouldn't be first, but I also didn't want to bury it the middle of all the other module changes. Open to suggestions. Change-Id: Ia1a96bcfb1977973c5b0b0a6b18a9242a745af12 Reviewed-on: https://go-review.googlesource.com/c/go/+/326209 Trust: Heschi Kreinick Run-TryBot: Heschi Kreinick TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov --- doc/go1.17.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/doc/go1.17.html b/doc/go1.17.html index 2a56b6d2703..6c53aaaa88c 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -279,12 +279,41 @@ Do not send CLs removing the interior tags from such phrases. mod download all.

+

//go:build lines

+ +

+ The go command now understands //go:build lines + and prefers them over // +build lines. The new syntax uses + boolean expressions, just like Go, and should be less error-prone. + As of this release, the new syntax is fully supported, and all Go files + should be updated to have both forms with the same meaning. To aid in + migration, gofmt now automatically + synchronizes the two forms. For more details on the syntax and migration plan, + see + https://golang.org/design/draft-gobuild. +

+ +

gofmt

+ gofmt (and go fmt) now synchronizes + //go:build lines with // +build lines. If a file + only has // +build lines, they will be moved to the appropriate + location in the file, and matching //go:build lines will be + added. Otherwise, // +build lines will be overwritten based on + any existing //go:build lines. For more information, see + https://golang.org/design/draft-gobuild. + +

Vet

-

New warning within buildtags

+

New warning for mismatched //go:build and // +build lines

- TODO(rsc): Describe changes to buildtags https://golang.org/cl/240609 + The vet tool now verifies that //go:build and + // +build lines are in the correct part of the file and + synchronized with each other. If they aren't, + gofmt can be used to fix them. For more + information, see + https://golang.org/design/draft-gobuild.

New warning for calling signal.Notify on unbuffered channels

@@ -638,6 +667,22 @@ func Foo() bool { +
go/format
+
+

+ The Source and + Node functions now + synchronize //go:build lines with // +build + lines. If a file only has // +build lines, they will be + moved to the appropriate location in the file, and matching + //go:build lines will be added. Otherwise, + // +build lines will be overwritten based on any existing + //go:build lines. For more information, see + https://golang.org/design/draft-gobuild. +

+
+
+
io/fs