A stricter Go code formatter that enforces additional formatting rules beyond gofmt while maintaining compatibility.
gofumpt is a stricter Go code formatter that builds upon the standard gofmt tool by enforcing additional formatting rules. It addresses the need for more consistent and cleaner code formatting in Go projects, automatically applying rules like removing unnecessary empty lines, ensuring consistent composite literal formatting, and properly grouping imports. The tool is designed as a drop-in replacement for gofmt, ensuring that all gofumpt-formatted code remains compatible with gofmt.
Go developers and teams who want to enforce stricter, more consistent code formatting standards in their projects beyond what gofmt provides. It's particularly useful for projects aiming to maintain high code quality and uniformity across large codebases.
Developers choose gofumpt because it offers a curated set of additional formatting rules that promote cleaner code, while maintaining full backwards compatibility with gofmt. Its seamless integration with editors and CI/CD pipelines makes it easy to adopt without disrupting existing workflows.
A stricter gofmt
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enforces stricter rules like removing unnecessary empty lines and ensuring consistent composite literal formatting, leading to cleaner and more readable Go code as demonstrated in the README examples.
All gofumpt-formatted code is valid for gofmt, ensuring no conflicts with existing Go tooling; running gofmt after gofumpt produces no changes, making it safe for adoption.
Acts as a direct replacement for gofmt in editors, IDEs, and CI/CD pipelines, with detailed setup guides for VS Code, GoLand, Vim, and others, minimizing workflow disruption.
Offers additional rules via the -extra flag, such as grouping adjacent parameters and avoiding naked returns, providing more control over code clarity without breaking compatibility.
The stricter formatting rules are subjective and may force stylistic changes that some developers or teams find unnecessary or prefer to handle differently, leading to resistance in adoption.
Setting up gofumpt in certain environments, like GoLand, requires manual configuration of file watchers with specific arguments, which can be cumbersome and error-prone compared to simpler tools.
While it extends gofmt, gofumpt does not allow disabling individual core rules, so teams must accept all enforced styles or avoid the tool entirely, which can be inflexible for specific needs.