3 ms·
You could always have your editor reformat files in gofumpt's way before viewing code or diffs, and reformat with go fmt when committing. I've never seen anyon
by dmurray 2y ago
You could always have your editor reformat files in gofumpt's way before viewing code or diffs, and reformat with go fmt when committing.
I've never seen anyone with a workflow like this (lots of people have the second part, of course, but not the first one), nor tooling that makes it a really natural thing to do, but wouldn't it work? There are some pain points if you ever want to pair program or if you use multiple tools to collaborate on code.
- cmcaine 2y agoNo, you'd likely get unrelated style changes in your commits. Read the gofumpt readme to understand why.
- dmurray 2y agoI see! Seems like neither formatter is completely rigid, and both respect some style decisions made by the programmer, so this level of automated reformatting isn't possible.
- jaeckel 2y ago> [...] nor tooling that makes it a really natural thing to do [...] If we ignore the fact that switching between those two formatters would "break" the formatting: There exist clean&smudge filters in Git, which could accomplish this technically. https://git-scm.com/docs/gitattributes#_filter https://git-scm.com/docs/gitattributes#_filter https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#filters_a https://git-scm.com/book/en/v2/Customizing-Git-Git-Attribute...