What problem does it solve?
This guide ensures Go code is consistently formatted, readable, and idiomatic across writing, reviewing, and refactoring, reducing style debates and preventing subtle bugs introduced by inconsistent patterns.
Core Features & Use Cases
- Formatting & Line Length: Enforce gofumpt-compatible formatting and a maximum line length of 120 characters for readable diffs and reviews.
- Import Grouping: Require three-group import ordering: standard library, third-party, then local module imports separated by blank lines.
- Naming & Receivers: Use short 1-2 character receiver names consistently and follow package, interface, and exported symbol naming best practices.
- Error Handling & Type Assertions: Always check errors, prefer wrapping with %w for context, and use the two-value form for type assertions unless proven safe.
- Design & Testing: Favor small interfaces, logical struct field ordering, focused functions with helper extraction, and table-driven tests for multi-case coverage.
- Use Case: Load this guide whenever writing, editing, reviewing, or linting any .go file to produce idiomatic, review-ready code.
Quick Start
Format and review the attached Go file to enforce gofumpt style, a 120-character line limit, three-group import ordering, 1-2 character receiver names, explicit error checks and wrapping, and table-driven tests where applicable.