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

Open
josharian opened this issue Aug 23, 2018 · 4 comments
Open

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

josharian opened this issue Aug 23, 2018 · 4 comments
Labels
GoCommand cmd/go NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@josharian
Copy link
Contributor

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

$ go tool -n compile
/Users/josh/go/tip/pkg/tool/darwin_amd64/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 Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 23, 2018
@josharian josharian added this to the Go1.12 milestone Aug 23, 2018
@rsc
Copy link
Contributor

rsc commented Sep 26, 2018

$(go env GOROOT)/bin/gofmt?

@zolotov
Copy link
Contributor

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 cmd/go label Nov 15, 2018
@bcmills
Copy link
Contributor

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

Flags:
  -all
        show all documentation for package
  -c    symbol matching honors case (paths not affected)
  -cmd
        show symbols with package docs even if package is a command
  -src
        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
@josharian
Copy link
Contributor Author

@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
/Users/josh/go/tip/pkg/tool/darwin_amd64/fix
$ go tool -n vet
/Users/josh/go/tip/pkg/tool/darwin_amd64/vet
$ go tool -n doc
/Users/josh/go/tip/pkg/tool/darwin_amd64/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
Labels
GoCommand cmd/go NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

5 participants