Uh oh!
There was an error while loading. Please reload this page.
Use gofumpt if available, and enable gofumpt linter - #3798
Merged
Conversation
thaJeztahforce-pushed
the
gofumpt_linting
branch
2 times, most recently
from
September 30, 2022 11:51
380d7fc to
a92c219ComparethaJeztah
marked this pull request as ready for review
September 30, 2022 11:51
thaJeztah
commented
Sep 30, 2022
MemberAuthor
@crazy-max@vvoland ptal 😄 |
thaJeztah
commented
Sep 30, 2022
| go list -f {{.Dir}} ./... | xargs gofmt -w -s -d | ||
| fmt: ## run gofumpt (if present) or gofmt | ||
| @if command -v gofumpt > /dev/null; then \ | ||
| gofumpt -w -d . ; \ |
MemberAuthor
There was a problem hiding this comment.
gofumpt automatically excludes vendor/ so no need to use go list
thaJeztah
commented
Sep 30, 2022
MemberAuthor
Hm... interesting; somehow my |
Looks like the linter uses an explicit -lang, which (for go1.19) results in some additional formatting for octal values. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
gofumpt provides a supserset of gofmt / go fmt, but not every developer may have it installed, so for situations where it's not available, fall back to gofmt. As our code has been formatted with gofumpt already, in most cases contributions will follow those formatting rules, but in some cases there may be a difference, which would already be flagged by manual code review, but let's also enable the gofumpt linter. With this change, `make fmt` will use gofumpt is available; gofumpt has been added to the dev-container, so `make -f docker.Makefile fmt` will always use it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztahforce-pushed
the
gofumpt_linting
branch
from
September 30, 2022 17:14
a92c219 to
c2f1671CompareCodecov Report
Additional details and impacted files@@ Coverage Diff @@## master #3798 +/- ##
=======================================
Coverage 59.21% 59.21% =======================================
Files 288 288 Lines 24605 24605 =======================================
Hits 14571 14571 Misses 9159 9159 Partials 875 875 |
thaJeztah
commented
Sep 30, 2022
| go list -f {{.Dir}} ./... | xargs gofmt -w -s -d | ||
| fmt: ## run gofumpt (if present) or gofmt | ||
| @if command -v gofumpt > /dev/null; then \ | ||
| gofumpt -w -d -lang=1.19 . ; \ |
MemberAuthor
There was a problem hiding this comment.
Looks like I need to add an explicit -lang=1.19, otherwise it doesn't pick up the go version for which to format. Probably because we don't have a go.mod
thaJeztah
commented
Oct 12, 2022
MemberAuthor
@crazy-max ptal 🤗 |
crazy-max
approved these changes
Oct 12, 2022
crazy-max
left a comment
Member
There was a problem hiding this comment.
LGTM if opt-in.
Do we want a scheduled worklow to fix-up and open PR as semi-automation process?
thaJeztah
commented
Nov 4, 2022
MemberAuthor
Let me bring this one in 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gofumpt (https://github.com/mvdan/gofumpt) provides a supserset of gofmt / go fmt, but not every developer may have
it installed, so for situations where it's not available, fall back to gofmt.
As our code has been formatted with gofumpt already, in most cases contributions
will follow those formatting rules, but in some cases there may be a difference,
which would already be flagged by manual code review, but let's also enable the
gofumpt linter.
With this change,
make fmtwill use gofumpt is available; gofumpt has beenadded to the dev-container, so
make -f docker.Makefile fmtwill always use it.