skills/go-naming/SKILL.md
Use when naming any Go identifier — packages, types, functions, methods, variables, constants, or receivers — to ensure idiomatic, clear names. Also use when a user is creating new types, packages, or exported APIs, even if they don't explicitly ask about naming conventions. Does not cover package organization (see go-packages).
npx skillsauth add cxuu/golang-skills go-namingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
scripts/check-naming.sh — Scans Go code for naming anti-patterns: SCREAMING_SNAKE_CASE constants, Get-prefixed getters, bad package names (util/helper/common), and receivers named "this"/"self". Run bash scripts/check-naming.sh --help for options.Names should:
Naming is more art than science—Go names tend to be shorter than in other languages.
What are you naming?
├─ Package → Short, lowercase, singular noun (no underscores, no mixedCaps)
├─ Interface → Method name + "-er" suffix when single-method (Reader, Writer)
├─ Receiver → 1-2 letter abbreviation of type (c for Client); consistent across methods
├─ Constant → MixedCaps; use iota for enums; no ALL_CAPS
├─ Exported func → Verb or verb-phrase in MixedCaps; no Get prefix for getters
├─ Variable → Length proportional to scope distance
│ ├─ Tiny scope (1-7 lines) → single letter (i, n, r)
│ ├─ Medium scope → short word (count, buf)
│ └─ Package-level / wide → descriptive (userAccountCount)
└─ Any name → Check: does it repeat package name or context? If yes, shorten it
Normative: All Go identifiers must use MixedCaps.
Underscores are allowed only in: test functions (TestFoo_InvalidInput),
generated code, and OS/cgo interop.
Normative: Packages must be lowercase with no underscores.
Short, lowercase, singular nouns. Avoid generic names like util, common,
helper — prefer specific names: stringutil, httpauth, configloader.
// Good: user, oauth2, tabwriter
// Bad: user_service, UserService, count (shadows var)
Read references/IDENTIFIERS.md when naming packages, deciding on import aliases, or choosing between generic and specific package names.
Advisory: One-method interfaces use "-er" suffix.
Name one-method interfaces by the method plus -er: Reader, Writer,
Formatter. Honor canonical method names (Read, Write, Close, String)
and their signatures.
Read references/IDENTIFIERS.md when defining new interfaces or implementing well-known method signatures.
Normative: Receivers must be short abbreviations, used consistently.
One or two letters abbreviating the type, consistent across all methods:
func (c *Client) Connect(), func (c *Client) Send().
Never use this or self.
Read references/IDENTIFIERS.md when choosing receiver names or ensuring consistency across methods.
Normative: Constants use MixedCaps, never ALL_CAPS or K prefix.
Name constants by role, not value: MaxRetries not Three,
DefaultPort not Port8080.
const MaxPacketSize = 512
const defaultTimeout = 30 * time.Second
Read references/IDENTIFIERS.md when naming constants or choosing between role-based and value-based names.
Normative: Initialisms maintain consistent case throughout.
Initialisms (URL, ID, HTTP, API) must be all uppercase or all lowercase:
HTTPClient, userID, ParseURL() — not HttpClient, orderId, ParseUrl().
Read references/IDENTIFIERS.md when using initialisms in compound names or for the full case table.
Advisory: No
Getprefix for simple accessors; use verb-like names for actions.
Getter for field owner is Owner(), not GetOwner(). Setter is
SetOwner(). Use Compute or Fetch for expensive operations.
When functions differ only by type, include type at the end:
ParseInt(), ParseInt64().
Read references/IDENTIFIERS.md when designing getter/setter APIs or naming function variants.
Variable naming balances brevity with clarity. Key principles:
i, v) for small scopes; longer,
descriptive names for larger scopesi for index,
r/w for reader/writer)users not userSlice, name not nameString_ prefix for package-level unexported
vars/consts to prevent shadowingfor i, v := range items { ... } // small scope
pendingOrders := filterPending(orders) // larger scope
const _defaultPort = 8080 // unexported global
Read references/VARIABLES.md when naming local variables in functions over 15 lines.
Go names should not feel repetitive when used. Consider the full context:
widget.New() not widget.NewWidget()p.Name() not p.ProjectName()sqldb, use Connection not DBConnectionRead references/REPETITION.md when a package name and its exported symbols feel redundant.
Never shadow Go's predeclared identifiers (error, string, len, cap,
append, copy, new, make, etc.) as variable, parameter, or type names.
For detailed guidance: See go-declarations — "Avoid Using Built-In Names"
section.
| Element | Rule | Example |
|---------|------|---------|
| Package | lowercase, no underscores | package httputil |
| Exported | MixedCaps, starts uppercase | func ParseURL() |
| Unexported | mixedCaps, starts lowercase | func parseURL() |
| Receiver | 1-2 letter abbreviation | func (c *Client) |
| Constant | MixedCaps, never ALL_CAPS | const MaxSize = 100 |
| Initialism | consistent case | userID, XMLAPI |
| Variable | length ~ scope size | i (small), userCount (large) |
| Built-in names | Never shadow predeclared identifiers | See go-declarations |
Validation: After renaming identifiers, run
bash scripts/check-naming.shto verify no naming anti-patterns remain. Then rungo build ./...to confirm the rename didn't break anything.
-er suffix or choosing receiver typesutil/common, or resolving import collisionsErrFoo) or custom error typestools
Use when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff. Also use when a user asks to write a test for a Go function, even if they don't mention specific patterns like table-driven tests or subtests. Does not cover benchmark performance testing (see go-performance).
development
Use when working with Go formatting, line length, nesting, naked returns, semicolons, or core style principles. Also use when a style question isn't covered by a more specific skill, even if the user doesn't reference a specific style rule. Does not cover domain-specific patterns like error handling, naming, or testing (see specialized skills). Acts as fallback when no more specific style skill applies.
development
Use when optimizing Go code, investigating slow performance, or writing performance-critical sections. Also use when a user mentions slow Go code, string concatenation in loops, or asks about benchmarking, even if the user doesn't explicitly mention performance patterns. Does not cover concurrent performance patterns (see go-concurrency).
development
Use when creating Go packages, organizing imports, managing dependencies, or deciding how to structure Go code into packages. Also use when starting a new Go project or splitting a growing codebase into packages, even if the user doesn't explicitly ask about package organization. Does not cover naming individual identifiers (see go-naming).