mvdan / gofumpt

A stricter gofmt
https://pkg.go.dev/mvdan.cc/gofumpt
BSD 3-Clause "New" or "Revised" License
3.15k stars 110 forks source link

Document WHEN generated code is touched and how to mitigate it #265

Closed 6543 closed 1 year ago

6543 commented 1 year ago

as #71 implemented by #150 ... it should ignore generated code.

but it does not at woodpecker codebase.

to reproduce:

  1. clone https://github.com/woodpecker-ci/woodpecker and checkout at e.g. at 56e66393
  2. make format to use gofumpt
  3. git diff should not show changed files but it does :(
6543 commented 1 year ago

solved by https://github.com/woodpecker-ci/woodpecker/pull/1654

mvdan commented 1 year ago

The README says:

Note that vendor directories are skipped unless given as explicit arguments. Similarly, the added rules do not apply to generated Go files unless they are given as explicit arguments.

You were using find to feed filenames explicitly to the tool, so these "skip" rules weren't kicking in. The change you applied is correct; you should generally be running gofumpt on the top-level directory to format everything.