go-style

Write and review Go code following idiomatic naming, control flow, and declaration conventions.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-style-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-style
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/go/go-style
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-style-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go developers often write code that compiles and passes linters but still reads poorly — stuttering names like http.HTTPClient, deeply nested happy paths, nil maps that panic, and inconsistent error or enum conventions. This Skill provides the human-judgment style rules that automated formatters cannot enforce, so Go code reads its intent at a glance. ## Core Features & Use Cases - Naming conventions: MixedCaps identifiers, scope-proportional name length, stutter-free package/type names, acronym casing (URL, not Url), boolean is/has/can prefixes, and constructor patterns (New vs NewTypeName). - Control flow and declarations: Flat happy paths with early returns, default-then-override instead of else chains, named booleans for complex conditions, and intentful declarations (:= vs var, initialized slices/maps, named composite literal fields). - Error, enum, and signature conventions: Lowercase error strings with package prefixes, Err-prefixed sentinels, Error-suffixed types, Unknown zero-value enums, and ≤4-parameter signatures with context.Context first. - Use Case: When reviewing a pull request, ask the AI to check the diff against Go style conventions — it will flag GetName() getters, StatusReady at iota 0, and capitalized error strings, each with the rule it violates and why clarity suffers. ## Quick Start Review this Go file for style and naming issues and explain each violation with its fix.

Frequently Asked Questions about go-style

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

FAQPage Schema
How do I name Go identifiers idiomatically?

Use MixedCaps without underscores, match name length to scope size, and avoid repeating the package name at the call site. Acronyms are all caps or all lower (URL, xmlParser), and boolean fields use is/has/can prefixes like isConnected.

How should Go error strings and sentinel errors be written?

Error strings must be fully lowercase including acronyms with no trailing punctuation, since they are wrapped mid-sentence. Sentinel errors use the Err prefix and include the package name, such as errors.New("mypackage: not found").

What is the difference between gofmt and Go style review?

gofmt, gofumpt, and goimports handle mechanical formatting automatically, while style review covers judgment calls linters miss: stuttering names, nested happy paths, nil map initialization, and unclear boolean naming. This Skill handles the clarity layer.

Why should Go enums have an Unknown zero value?

A declared-but-uninitialized enum variable silently becomes 0, so placing StatusUnknown at iota 0 prevents code from treating an unset value as a real state like StatusReady. Alternatively, start real values at iota + 1.

When should I use pointers versus values for Go function arguments?

Pass small types like string, int, bool, and time.Time by value. Use pointers when the function mutates the argument, the struct exceeds roughly 128 bytes, or nil carries meaning such as an optional update field.