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

proposal: cmd/gofmt: deprecate 'gofmt' in favor of 'go fmt' #33263

ialidzhikov opened this issue Jul 24, 2019 · 5 comments

proposal: cmd/gofmt: deprecate 'gofmt' in favor of 'go fmt' #33263

ialidzhikov opened this issue Jul 24, 2019 · 5 comments


Copy link

@ialidzhikov ialidzhikov commented Jul 24, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

What did you expect to see?

Currently is gofmt and go fmt are both used in the community for formatting. go fmt runs gofmt -l -w on packages. The args for gofmt are system paths, for go fmt - packages.
Can't we just use go fmt with the full set of gofmt args and depricate gofmt?
At least for a newbies it's a little bit confusing gofmt vs go fmt - why there are 2 things that does appr. the same thing?

What did you see instead?

Copy link

@julieqiu julieqiu commented Jul 24, 2019

/cc @bcmills

Copy link

@dpinela dpinela commented Jul 25, 2019

gofmt can be used as a Unix-style filter, which reads source code from stdin and prints the formatted source to stdout. go fmt currently cannot - invoking it without arguments formats the package in the current working directory - although I think that could be changed without breaking the latter use case.

At least in the abstract, I like the idea of merging the two or explicitly recommending one. It would, to some extent, parallel how go vet became the recommended way to invoke vet, rather than using go tool vet directly.

Copy link

@bcmills bcmills commented Jul 25, 2019

@bcmills bcmills added this to the Unplanned milestone Jul 25, 2019
@bcmills bcmills changed the title cmd/go: gofmt vs go fmt cmd/gofmt: deprecate 'gofmt' in favor of 'go fmt' Sep 16, 2019
@bcmills bcmills added Proposal and removed NeedsInvestigation labels Sep 16, 2019
@bcmills bcmills modified the milestones: Unplanned, Proposal Sep 16, 2019
@bcmills bcmills changed the title cmd/gofmt: deprecate 'gofmt' in favor of 'go fmt' proposal: cmd/gofmt: deprecate 'gofmt' in favor of 'go fmt' Sep 16, 2019
Copy link

@mvdan mvdan commented Dec 1, 2019

I don't think this is a good idea; see @rsc's comment in a related issue.

I guess we could teach go fmt to behave like gofmt given some flag or knob, but there are still lots of programs and scripts out there that require gofmt. Would we simply break those?

It's also worth noting that gofmt is a relatively small and simple binary, while go fmt is part of cmd/go, which is a comparatively massive suite of tools, often including a compiler and linker.

Copy link

@rsc rsc commented Dec 4, 2019

Duplicate of #35258.

@rsc rsc closed this Dec 4, 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
6 participants
You can’t perform that action at this time.