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: gofmt vs go fmt #33263

Open
ialidzhikov opened this issue Jul 24, 2019 · 3 comments

Comments

@ialidzhikov
Copy link

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

This comment has been minimized.

Copy link

commented Jul 24, 2019

/cc @bcmills

@dpinela

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

@bcmills bcmills added this to the Unplanned milestone Jul 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.