-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.21.0 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
go clean -n -gcflags=-S
What did you expect to see?
I expected the go command to reject the -gcflags flag because it makes no sense for that subcommand.
What did you see instead?
It quietly succeeded.
Many of the go subcommands are sensitive not just to which packages match the package pattern, but the specific set of source files selected for a build configuration. These call work.AddBuildFlags to register the flags that affect source selection, but this function also registers many flags that only affect actual compilation and linking.
- The
cleancommand is sensitive to source file selection because it finds all source files in the a package that have a correspondingly named binary in the directory (but are not part of package main) to delete the binaries. - The
fixcommand useswork.AddBuildFlags, but appears not to be sensitive to any build flags, because it usespkg.InternalAllGoFiles()to list source files, which should returns all source files regardless of source file selection. - The
generatecommand only searches forgo:generatedirectives in matched source files.
The full set of build flags makes sense for build, install, get, run, test, vet, and list because they all build source files (vet and list -export both invoke the toolchain to create up-to-date export files).
cc @bcmills
dmitshur and bcmills
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.