-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use gofumpt to format code #2975
Conversation
gofumpt (mvdan.cc/gofumpt) is a fork of gofmt with stricter rules. Brought to you by git ls-files \*.go | grep -v ^vendor/ | xargs gofumpt -s -w Looking at the diff, all these changes make sense. Also, replace gofmt with gofumpt in golangci.yml. Signed-off-by: Kir Kolyshkin <[email protected]>
Perhaps we can squeeze this and #2974 in before 1.0? |
@@ -6,4 +6,4 @@ run: | |||
|
|||
linters: | |||
enable: | |||
- gofmt | |||
- gofumpt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can gofmt
pass after gofumpt
? If so, can we run both? If gofumpt
doesn't get updated in the future, then we can fall back to gofmt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can gofmt pass after gofumpt?
Yes it can. gofumpt is a superset.
If so, can we run both?
Does not make sense to me, as they are 99% similar and gofumpt is doing its job. Frankly, gofmt
is somewhat abandoned, see e.g. golang/go#6996.
If gofumpt doesn't get updated in the future.
Oh, you mean to sort of re-check gofumpt results with gofmt. For that, we need to run gofumpt first in "fixing" mode, then run gofmt on top of it, which is a separate job.
golangci-lint runs all checkers in parallel, and so if we just add both gofumpt and gofmt, we'll end up double amount of linter warnings.
Now, I hope that we should trust @mvdan's good track record and rely on his promise of "running gofmt after gofumpt should be a no-op".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR: we don't want both gofumpt
and gofmt
as it will just double the amount of linter warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, gofumpt output is designed to be a strict subset of gofmt output. If you see gofmt changing a program after gofumpt ran on it, or if gofumpt itself isn't stable when run twice in a row, that's a bug. There have been a few of those over the years, but they should be rare and relatively easy to fix when reported.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Tentatively set 1.0.0 milestone as this seems like a good fit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It is interesting that so many of these were allowed.
gofumpt (https://mvdan.cc/gofumpt) is a fork of gofmt with stricter rules.
Brought to you by
Looking at the diff, all these changes make sense.
Also, replace gofmt with gofumpt in golangci.yml.