3 ms·
Helpfully, you can debate between "gofmt", "gofmt -s" and "gofumpt". I actually like how gofumpt formats stuff but ... nobody else on the team would have it, s
by jrockway 2y ago
Helpfully, you can debate between "gofmt", "gofmt -s" and "gofumpt".
I actually like how gofumpt formats stuff but ... nobody else on the team would have it, so it would make things worse.
- autarch 2y agoYeah, there's still a few options. But try running `perltidy --help`. Even that doesn't really give you a sense of how many options there are because many of the options are not booleans, but instead take several enum values indicating which style to choose.
- dmurray 2y agoYou 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...