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
GoCommand NeedsDecision


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

@josharian josharian added the NeedsDecision label Aug 23, 2018
@josharian josharian added this to the Go1.12 milestone Aug 23, 2018
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.

@bcmills bcmills added the GoCommand label Nov 15, 2018
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 removed this from the Go1.12 milestone Nov 15, 2018
@bcmills bcmills added this to the Go1.13 milestone 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 removed this from the Go1.13 milestone Jul 8, 2019
@andybons andybons added this to the Go1.14 milestone Jul 8, 2019
@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
GoCommand NeedsDecision
None yet

No branches or pull requests

5 participants