Golangci-lint: Add gofumpt

Created on 10 Apr 2019  路  14Comments  路  Source: golangci/golangci-lint

Include https://github.com/mvdan/gofumpt in set of linters.

help wanted new update

Most helpful comment

@teivah thanks for working on the PR, pleased to see that it was merged

A quick scan of the PR suggests it doesn't currently map the golangci-lint "Autofix" functionality to a gofumpt -s -w equivalent, like it does for the gofmt linter. It would be good if that could be added, as then we could switch our .golanci-lint.yml to disable the fmt linter and switch to gofumpt wholesale

cc @mvdan as he'd probably be interested in knowing that this work is taking place to add gofumpt to golangci-lint

All 14 comments

Hi, nice tool, thank you!
Pull requests are welcome

Given gofumpt/gofumports does everything that gofmt / goimports would do, what is the preference for applying this?

Enforce a stricter format than gofmt, while being backwards compatible. That is, gofumpt is happy with a subset of the formats that gofmt is happy with.
The tool is a modified fork of gofmt, so it can be used as a drop-in replacement. Running gofmt after gofumpt should be a no-op.

Would gofumpt (and gofumports) be added as an entirely new linter, or options for gofmt/goimports ?

Hey there, I'm also interested in adding gofumpt/goimports.

Would gofumpt (and gofumports) be added as an entirely new linter, or options for gofmt/goimports ?

About new linter vs gofmt option is see pros and cons:

  • new linter pros: more clean to add/remove the linter if it gets deprecated
  • cons: does not make sense to run gofmt/goimports if gofumpt/gofumports are enabled since they are a superset of gofmt/goimports, so how to handle this?

Hey, sorry for long responses, we are currently trying to deal with bugs and preparing to go1.14, so very low of capacity.

I'm also not sure how to deal with linters that superset other linters, e.g. we can't just auto-ignore them.

Maybe we can just start adding it as a new linter and disable gofmt/goimports manually.

@teivah thanks for working on the PR, pleased to see that it was merged

A quick scan of the PR suggests it doesn't currently map the golangci-lint "Autofix" functionality to a gofumpt -s -w equivalent, like it does for the gofmt linter. It would be good if that could be added, as then we could switch our .golanci-lint.yml to disable the fmt linter and switch to gofumpt wholesale

cc @mvdan as he'd probably be interested in knowing that this work is taking place to add gofumpt to golangci-lint

Since gofump returns already formatted file instead of diff, so we need to use something like this https://github.com/sergi/go-diff library to create a diff then use extractIssuesFromPatch function

@dnwe Could you please test the #1239 ?

This has been added in #1177.

@invidian you are right, the gofumpt linter was added in that PR, but it doesn't support autofixing, I'm adding it in the #1239

@SVilgelm, hello!

Could you tell me something about this?
https://github.com/mvdan/gofumpt/issues/79

@Antonboom latest master has an updated version of gofumpt and it works correctly for the example you provided.
The PR with the update: #1228

Then I have to wait v1.28.4
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsm picture jsm  路  5Comments

ferhatelmas picture ferhatelmas  路  4Comments

kpeu3i picture kpeu3i  路  3Comments

lnshi picture lnshi  路  4Comments

KeepMasterBranch picture KeepMasterBranch  路  3Comments