Closed silverwind closed 12 months ago
Correct, there isn't a gofumpt -r
because you should use gofmt -r
. There are three reasons for this:
1) gofmt -r
works, and gofumpt is not in the business of pattern rewrites.
2) gofmt -r
has always been quite limited by design; https://github.com/rsc/rf is their new attempt and it's far more powerful. I don't see a point in investing more time into gofmt -r
, particularly since neither approach has anything to do with canonical formatting.
3) It is a surprisingly complex chunk of code that we don't need to maintain on our end.
Also note that our README says:
It can be used as a drop-in replacement to format your Go code
I think that still holds true; at least in my head, rewrite rules have little to do with canonical formatting like gofmt
or gofumpt
.
In any case, I'm happy to get input on better ways to document both of these aspects :)
I guess in the end such "rewrites" are the job of a linter's autofix, e.g. ruff --fix
or eslint --fix
serve the purpose very will in those respective languages, but golang's linter's are rudimentary compared to those two, golangci's --fix
is borderline useless.
I still hope a better go linter arises, golangci really pales in comparision to what other linters can do.
I'm going to close this then, as it seems like the misunderstanding is solved. Still happy to receive suggestions in terms of better wording - in that case please send a PR.
I would like to rewrite
interface{}
toany
, but the docs seem unclear about rewrite rules:What does this statement mean? Does one need to run
gofmt
beforegofumpt
to be able to use rewrite rules? A docs clarification would be nice.Also, I wonder how a tool that is advertized as a "drop-in replacement" does not support all features of the tool it's meant to replace.