mirror of
https://github.com/golang/go
synced 2024-11-23 23:50:08 -07:00
cmd/go: set the "generate" build tag in go generate, per design doc
And use it in two internal windows packages, so they don't show up in "go list std" or binary releases on non-Windows platforms. Fixes #31920 Change-Id: Iaa292b6015c9d7310dd677c9e296006440ba5e27 Reviewed-on: https://go-review.googlesource.com/c/go/+/175983 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0047353c53
commit
41df5aeb7f
@ -525,7 +525,9 @@
|
||||
// they are treated as a single package. Within a package, generate processes the
|
||||
// source files in a package in file name order, one at a time. Within
|
||||
// a source file, generate runs generators in the order they appear
|
||||
// in the file, one at a time.
|
||||
// in the file, one at a time. The go generate tool also sets the build
|
||||
// tag "generate" so that files may be examined by go generate but ignored
|
||||
// during build.
|
||||
//
|
||||
// If any generator returns an error exit status, "go generate" skips
|
||||
// all further processing for that package.
|
||||
|
@ -114,7 +114,9 @@ one at a time. If the command line lists .go files from a single directory,
|
||||
they are treated as a single package. Within a package, generate processes the
|
||||
source files in a package in file name order, one at a time. Within
|
||||
a source file, generate runs generators in the order they appear
|
||||
in the file, one at a time.
|
||||
in the file, one at a time. The go generate tool also sets the build
|
||||
tag "generate" so that files may be examined by go generate but ignored
|
||||
during build.
|
||||
|
||||
If any generator returns an error exit status, "go generate" skips
|
||||
all further processing for that package.
|
||||
@ -161,6 +163,9 @@ func runGenerate(cmd *base.Command, args []string) {
|
||||
log.Fatalf("generate: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
cfg.BuildContext.BuildTags = append(cfg.BuildContext.BuildTags, "generate")
|
||||
|
||||
// Even if the arguments are .go files, this loop suffices.
|
||||
printed := false
|
||||
for _, pkg := range load.Packages(args) {
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build generate
|
||||
|
||||
package windows
|
||||
|
||||
//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build generate
|
||||
|
||||
package registry
|
||||
|
||||
//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go
|
||||
|
Loading…
Reference in New Issue
Block a user