Go version
latest
Output of go env
in your module/workspace:
N/A
What did you do?
go tool .... <any number of flags>
What did you see happen?
The command supports on a very minimal set of flags (which are not documented, fwiw https://github.com/golang/go/issues/71502). All(?) other commands in the Go toolchain support a large range of flags to customize, troubleshoot, etc.
In particular, go run
does, which feels like a very close parallel to go tool
. It seems odd I can do -x
to debug go run
but not go tool
, for instance.
What did you expect to see?
All build flags available.
Note: -n
is in conflict, though.
Comment From: gabyhelp
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: matloob
cc @ConradIrwin
I think this is reasonable to do, we'd just have to make sure we're adding the right set of flags. All we'd have to do is to call work.AddBuildFlags (with the appropriate BuildFlagMask).
Comment From: ConradIrwin
Seems reasonable to me; I didn't add them originally because it seemed out of scope (go tool --flag-flag-flag
is no longer a useful time saver, and you're back to needing a wrapper script or be a one off).
That said, I don't see any downside
Comment From: matloob
@howardjohn do you have a use case for the flags other than -n and -x? Maybe we can start by just adding those?
I agree that the usefulness of providing several flags to go tool
seems limited.
Comment From: seankhliao
you could maybe pass in build flags with GOFLAGS
if necessary for debugging.
Comment From: seankhliao
I saw a comment somewhere about being unable to use golang-migrate/migrate
, which uses -tags
to build with support for different database drivers https://github.com/golang-migrate/migrate/tree/master/cmd/migrate