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

Does gofumpt ignore folders like testdata? #260

Closed denizgursoy closed 1 year ago

denizgursoy commented 1 year ago

I have a .go source file in a testdata directory. When I execute gofumpt -l -w -extra . it does not ignore the files under testdata. Should it ignore? or How I can ignore the testdata folders

abhinav commented 1 year ago

How are you invoking gofumpt? gofumpt operates on a list of files, so if you give it a testdata/ file, it'll change it.

mvdan commented 1 year ago

The short answer is no; we do skip vendor directories when walking directory trees, but we don't skip testdata.

https://github.com/mvdan/gofumpt/issues/250 has some more discussion on similar problems.

The more I think about it over time, the more I'm starting to think that we should skip both vendor and testdata directories when walking. If one really wants to format those, it would always possible to explicitly do so via gofumpt -l -w testdata vendor, for example.