Skip to content

Makefile: Switch from gitalyfmt to gofumpt

Patrick Steinhardt requested to merge pks-gofumpt into master

We have hosted our own formatter via the gitalyfmt package. While this has served us alright, there are (subjectively) better alternatives to having our own formatter.

One of these alternatives is gofumpt, which is a stricter version of gofmt adding a few additional rules on top:

- No empty lines at the beginning or end of a function.
- No empty lines around a lone statement (or comment) in a block.
- No empty lines before a simple error check.
- Composite literals should use newlines consistently.
- Empty field lists should use a single line.
- std imports must be in a separate group at the top.
- Short case clauses should take a single line.
- Multiline top-level declarations must be separated by empty lines.
- Single var declarations should not be grouped with parentheses.
- Contiguous top-level declarations should be grouped together.
- Simple var-declaration statements should use short assignments.
- The -s code simplification flag is enabled by default.
- Octal integer literals should use the 0o prefix on modules using Go 1.13 and later.
- Comments which aren't Go directives should start with a
  whitespace.

To me, these rules all sound agreeable and should enforce a stricter coding style across the project. So let's switch over to use this formatter and remove our own homegrown one.

Merge request reports