Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: provide some way to get the gofmt binary path #27166

josharian opened this issue Aug 23, 2018 · 4 comments

cmd/go: provide some way to get the gofmt binary path #27166

josharian opened this issue Aug 23, 2018 · 4 comments


Copy link

@josharian josharian commented Aug 23, 2018

We can ask cmd/go for the path to cmd/compile:

$ go tool -n compile

There does not seem to be any way to ask cmd/go where the gofmt binary is.

$ go tool -n fmt
go tool: no such tool "fmt"
$ go fmt -n
can't load package: package .: found packages main (w.go) and p (x.go) in /Users/josh/go/tip/src

cc @rsc @bcmills

Copy link

@rsc rsc commented Sep 26, 2018

$(go env GOROOT)/bin/gofmt?

Copy link

@zolotov zolotov commented Sep 27, 2018

@rsc as I said in the related issue, OS-specific distributions (like deb or rpm packages) doesn't always contain gofmt binary in GOROOT/bin.

Copy link

@bcmills bcmills commented Nov 15, 2018

Compare go fix, go vet, and go doc:

$ GO111MODULE=off go fix -n
flag provided but not defined: -n
usage: go fix [packages]
Run 'go help fix' for details.

$ GO111MODULE=off go vet -n
can't load package: package .: no Go files in /tmp/tmp.L5dpPjzEzQ

$ GO111MODULE=off go doc -n
flag provided but not defined: -n
Usage of [go] doc:
        go doc
        go doc <pkg>
        go doc <sym>[.<method>]
        go doc [<pkg>].<sym>[.<method>]
        go doc <pkg> <sym>[.<method>]
For more information run
        go help doc

        show all documentation for package
  -c    symbol matching honors case (paths not affected)
        show symbols with package docs even if package is a command
        show source code for symbol
  -u    show unexported symbols as well as exported
exit status 2

Arguably those should all be consistent, in that they invoke other tools with flags set by cmd/go.

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 15, 2018
Copy link
Contributor Author

@josharian josharian commented Nov 15, 2018

@bcmills maybe I'm missing something, but I think the thing that should be consistent is go tool -n <toolname>. fix, vet, and doc currently at least pass that test:

$ go tool -n fix
$ go tool -n vet
$ go tool -n doc
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants