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

Closed
ialidzhikov opened this issue Jul 24, 2019 · 5 comments
Closed

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

ialidzhikov opened this issue Jul 24, 2019 · 5 comments

Comments

@ialidzhikov
Copy link

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?

@julieqiu
Copy link
Member

/cc @bcmills

@julieqiu julieqiu added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 24, 2019
@dpinela
Copy link
Contributor

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.

@bcmills
Copy link
Contributor

bcmills commented Jul 25, 2019

CC @ianthehat @jayconrod

@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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. 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
@mvdan
Copy link
Member

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.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2019

Duplicate of #35258.

@rsc rsc closed this as completed Dec 4, 2019
@golang golang locked and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants