go-code-style

Enforce gofumpt formatting, 120-character lines, and three-group import ordering in Go files.

Updated Mar 28, 2026
One-click install
npx skills add https://github.com/MisLink/agentry --skill go-code-style-mislink
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-code-style
Source: https://github.com/MisLink/agentry/tree/main/agents/.agents/skills/go-code-style
Command: npx skills add https://github.com/MisLink/agentry --skill go-code-style-mislink

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about go-code-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce consistent Go code style and formatting across my projects?

To enforce consistent Go code style, apply gofumpt-compatible formatting with a maximum 120-character line limit. This ensures readable diffs and standardized code structure across all modules and project reviews.

What is the correct way to group imports in Golang?

The correct way to group imports in Golang is using a three-group ordering: standard library, third-party packages, then local module imports. These groups must be separated by blank lines for clarity.

How should I handle errors and type assertions in idiomatic Go code?

Handle errors in idiomatic Go by always checking them and wrapping with %w for context. For type assertions, use the two-value form unless the assertion is proven safe to prevent panic risks.

What are the best practices for naming receivers and writing tests in Go?

Best practices for naming receivers in Go require using short, consistent 1-2 character names. For testing, write table-driven tests to efficiently manage multi-case coverage and ensure robust validation.

Can I use this Go code style guide for linting and refactoring existing files?

Yes, you can use this Go code style guide for linting and refactoring existing files. It applies to all Go development workflows, including editing and reviewing, to produce idiomatic, review-ready source code.

Does this guide support structuring interfaces and struct fields?

Yes, this guide supports structuring interfaces and struct fields by favoring small interfaces and logical struct field ordering. It also encourages focused functions with helper extraction for better code maintainability.