← Back to Skills Marketplace
samber

Golang Naming

by Samuel Berthe · GitHub ↗ · v1.1.1 · MIT-0
cross-platform ⚠ suspicious
146
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install golang-naming
Description
Go (Golang) naming conventions — covers packages, constructors, structs, interfaces, constants, enums, errors, booleans, receivers, getters/setters, function...
README (SKILL.md)

Community default. A company skill that explicitly supersedes samber/cc-skills-golang@golang-naming skill takes precedence.

Go Naming Conventions

Go favors short, readable names. Capitalization controls visibility — uppercase is exported, lowercase is unexported. All identifiers MUST use MixedCaps, NEVER underscores.

"Clear is better than clever." — Go Proverbs

"Design the architecture, name the components, document the details." — Go Proverbs

To ignore a rule, just add a comment to the code.

Quick Reference

Element Convention Example
Package lowercase, single word json, http, tabwriter
File lowercase, underscores OK user_handler.go
Exported name UpperCamelCase ReadAll, HTTPClient
Unexported lowerCamelCase parseToken, userCount
Interface method name + -er Reader, Closer, Stringer
Struct MixedCaps noun Request, FileHeader
Constant MixedCaps (not ALL_CAPS) MaxRetries, defaultTimeout
Receiver 1-2 letter abbreviation func (s *Server), func (b *Buffer)
Error variable Err prefix ErrNotFound, ErrTimeout
Error type Error suffix PathError, SyntaxError
Constructor New (single type) or NewTypeName (multi-type) ring.New, http.NewRequest
Boolean field is, has, can prefix on fields and methods isReady, IsConnected()
Test function Test + function name TestParseToken
Acronym all caps or all lower URL, HTTPServer, xmlParser
Variant: context WithContext suffix FetchWithContext, QueryContext
Variant: in-place In suffix SortIn(), ReverseIn()
Variant: error Must prefix MustParse(), MustLoadConfig()
Option func With + field name WithPort(), WithLogger()
Enum (iota) type name prefix, zero-value = unknown StatusUnknown at 0, StatusReady
Named return descriptive, for docs only (n int, err error)
Error string lowercase (incl. acronyms), no punctuation "image: unknown format", "invalid id"
Import alias short, only on collision mrand "math/rand", pb "app/proto"
Format func f suffix Errorf, Wrapf, Logf
Test table fields got/expected prefixes input string, expected int

MixedCaps

All Go identifiers MUST use MixedCaps (or mixedCaps). NEVER use underscores in identifiers — the only exceptions are test function subcases (TestFoo_InvalidInput), generated code, and OS/cgo interop. This is load-bearing, not cosmetic — Go's export mechanism relies on capitalization, and tooling assumes MixedCaps throughout.

// ✓ Good
MaxPacketSize
userCount
parseHTTPResponse

// ✗ Bad — these conventions conflict with Go's export mechanism and tooling expectations
MAX_PACKET_SIZE   // C/Python style
max_packet_size   // snake_case
kMaxBufferSize    // Hungarian notation

Avoid Stuttering

Go call sites always include the package name, so repeating it in the identifier wastes the reader's time — http.HTTPClient forces parsing "HTTP" twice. A name MUST NOT repeat information already present in the package name, type name, or surrounding context.

// Good — clean at the call site
http.Client       // not http.HTTPClient
json.Decoder      // not json.JSONDecoder
user.New()        // not user.NewUser()
config.Parse()    // not config.ParseConfig()

// In package sqldb:
type Connection struct{}  // not DBConnection — "db" is already in the package name

// Anti-stutter applies to ALL exported types, not just the primary struct:
// In package dbpool:
type Pool struct{}        // not DBPool
type Status struct{}      // not PoolStatus — callers write dbpool.Status
type Option func(*Pool)   // not PoolOption

Frequently Missed Conventions

These conventions are correct but non-obvious — they are the most common source of naming mistakes:

Constructor naming: When a package exports a single primary type, the constructor is New(), not NewTypeName(). This avoids stuttering — callers write apiclient.New() not apiclient.NewClient(). Use NewTypeName() only when a package has multiple constructible types (like http.NewRequest, http.NewServeMux).

Boolean struct fields: Unexported boolean fields MUST use is/has/can prefix — isConnected, hasPermission, not bare connected or permission. The exported getter keeps the prefix: IsConnected() bool. This reads naturally as a question and distinguishes booleans from other types.

Error strings are fully lowercase — including acronyms. Write "invalid message id" not "invalid message ID", because error strings are often concatenated with other context (fmt.Errorf("parsing token: %w", err)) and mixed case looks wrong mid-sentence. Sentinel errors should include the package name as prefix: errors.New("apiclient: not found").

Enum zero values: Always place an explicit Unknown/Invalid sentinel at iota position 0. A var s Status silently becomes 0 — if that maps to a real state like StatusReady, code can behave as if a status was deliberately chosen when it wasn't.

Subtest names: Table-driven test case names in t.Run() should be fully lowercase descriptive phrases: "valid id", "empty input" — not "valid ID" or "Valid Input".

Detailed Categories

For complete rules, examples, and rationale, see:

  • Packages, Files & Import Aliasing — Package naming (single word, lowercase, no plurals), file naming conventions, import alias patterns (only use on collision to avoid cognitive load), and directory structure.

  • Variables, Booleans, Receivers & Acronyms — Scope-based naming (length matches scope: i for 3-line loops, longer names for package-level), single-letter receiver conventions (s for Server), acronym casing (URL not Url, HTTPServer not HttpServer), and boolean naming patterns (isReady, hasPrefix).

  • Functions, Methods & Options — Getter/setter patterns (Go omits Get so user.Name() reads naturally), constructor conventions (New or NewTypeName), named returns (for documentation only), format function suffixes (Errorf, Wrapf), and functional options (WithPort, WithLogger).

  • Types, Constants & Errors — Interface naming (Reader, Closer suffix with -er), struct naming (nouns, MixedCaps), constants (MixedCaps, not ALL_CAPS), enums (type name prefix like StatusReady), sentinel errors (ErrNotFound variables), error types (PathError suffix), and error message conventions (lowercase, no punctuation).

  • Test Naming — Test function naming (TestFunctionName), table-driven test field conventions (input, expected), test helper naming, and subcase naming patterns.

Common Mistakes

Mistake Fix
ALL_CAPS constants Go reserves casing for visibility, not emphasis — use MixedCaps (MaxRetries)
GetName() getter Go omits Get because user.Name() reads naturally at call sites. But Is/Has/Can prefixes are kept for boolean predicates: IsHealthy() bool not Healthy() bool
Url, Http, Json acronyms Mixed-case acronyms create ambiguity (HttpsUrl — is it Https+Url?). Use all caps or all lower
this or self receiver Go methods are called frequently — use 1-2 letter abbreviation (s for Server) to reduce visual noise
util, helper packages These names say nothing about content — use specific names that describe the abstraction
http.HTTPClient stuttering Package name is always present at call site — http.Client avoids reading "HTTP" twice
user.NewUser() constructor Single primary type uses New()user.New() avoids repeating the type name
connected bool field Bare adjective is ambiguous — use isConnected so the field reads as a true/false question
"invalid message ID" error Error strings must be fully lowercase including acronyms — "invalid message id"
StatusReady at iota 0 Zero value should be a sentinel — StatusUnknown at 0 catches uninitialized values
"not found" error string Sentinel errors should include the package name — "mypackage: not found" identifies the origin
userSlice type-in-name Types encode implementation detail — users describes what it holds, not how
Inconsistent receiver names Switching names across methods of the same type confuses readers — use one name consistently
snake_case identifiers Underscores conflict with Go's MixedCaps convention and tooling expectations — use mixedCaps
Long names for short scopes Name length should match scope — i is fine for a 3-line loop, userIndex is noise
Naming constants by value Values change, roles don't — DefaultPort survives a port change, Port8080 doesn't
FetchCtx() context variant WithContext is the standard Go suffix — FetchWithContext() is instantly recognizable
sort() in-place but no In Readers assume functions return new values. SortIn() signals mutation
parse() panicking on error MustParse() warns callers that failure panics — surprises belong in the name
Mixing With*, Set*, Use* Consistency across the codebase — With* is the Go convention for functional options
Plural package names Go convention is singular (net/url not net/urls) — keeps import paths consistent
Wrapf without f suffix The f suffix signals format-string semantics — Wrapf, Errorf tell callers to pass format args
Unnecessary import aliases Aliases add cognitive load. Only alias on collision — mrand "math/rand"
Inconsistent concept names Using user/account/person for the same concept forces readers to track synonyms — pick one name

Enforce with Linters

Many naming convention issues are caught automatically by linters: revive, predeclared, misspell, errname. See samber/cc-skills-golang@golang-linter skill for configuration and usage.

Cross-References

  • → See samber/cc-skills-golang@golang-code-style skill for broader formatting and style decisions
  • → See samber/cc-skills-golang@golang-structs-interfaces skill for interface naming depth and receiver design
  • → See samber/cc-skills-golang@golang-linter skill for automated enforcement (revive, predeclared, misspell, errname)
Usage Guidance
This skill is a focused Go naming/style reference and its contents are coherent and useful. Two things to consider before installing: (1) The registry metadata marks the 'go' binary as required and grants the agent permission to run Bash commands for go, golangci-lint and git — that is unnecessary for a pure style guide and would allow the agent to execute local tooling if it runs automatically. (2) The skill is instruction-only (no code to inspect beyond the docs) and points to a GitHub homepage — review that repo yourself if you want full provenance. If you want to minimize risk, ask the platform to remove or restrict the allowed-tools/execution permissions (so the skill cannot run go/linters/git automatically) or only enable the skill in contexts where running local tools is acceptable.
Capability Analysis
Type: OpenClaw Skill Name: golang-naming Version: 1.1.1 The skill bundle is a comprehensive guide for Go naming conventions, providing detailed documentation and evaluation cases for idiomatic coding practices. All files, including SKILL.md and the reference markdown files, are strictly aligned with the stated purpose of assisting an AI agent in writing and reviewing Go code. There are no indicators of malicious intent, prompt injection attacks, or unauthorized system access.
Capability Assessment
Purpose & Capability
The name/description promise a naming/style guidance skill. The registry lists the 'go' binary as required and the skill header permits running Bash(go:*), golangci-lint, and git — none of which are necessary for static naming guidance. Requiring a local 'go' binary or granting execution of go/golangci-lint/git is disproportionate to an instruction-only naming guide.
Instruction Scope
The SKILL.md content is a focused, detailed naming/style guide and does not instruct the agent to read arbitrary files, access secrets, or exfiltrate data. However the skill header's allowed-tools list implies the agent may run code/commands (go, linters, git) even though the prose does not require them; that expands runtime scope beyond the documented guidance.
Install Mechanism
This is instruction-only and has no install spec or downloads. That minimizes disk/runtime risk — nothing is written or installed by the skill itself.
Credentials
The skill requests no environment variables, no credentials, and no config paths. The lack of secrets/keys requested is proportionate to a documentation/style guide.
Persistence & Privilege
always:false (normal) and model invocation is allowed (default). The skill is not user-invocable but may be invoked autonomously by the agent when triggered. Combined with the broad allowed-tools (shell access to go, linters, git), autonomous invocation increases the potential for the agent to run local commands — consider this when enabling the skill.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install golang-naming
  3. After installation, invoke the skill by name or use /golang-naming
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.1.1
- Added evals/evals.json to support evaluation configurations. - Updated metadata and version in SKILL.md to 1.1.1. - Minor documentation adjustments; no breaking or behavioral changes.
v0.1.0
Initial release of golang-naming skill. - Provides comprehensive Go naming conventions for packages, types, functions, methods, constants, enums, errors, booleans, receivers, and more. - Includes quick reference table, category breakdowns, and rationale for best practices. - Clarifies commonly misunderstood rules: MixedCaps, ALL_CAPS avoidance, anti-stutter, boolean and error naming, enum zero values, and subtest phrasing. - Covers handling of acronyms, functional options (`WithX`), constructor names, and import aliasing. - Documented as a non-invocable, organization-wide skill for code write/review tasks involving naming in Go.
Metadata
Slug golang-naming
Version 1.1.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is Golang Naming?

Go (Golang) naming conventions — covers packages, constructors, structs, interfaces, constants, enums, errors, booleans, receivers, getters/setters, function... It is an AI Agent Skill for Claude Code / OpenClaw, with 146 downloads so far.

How do I install Golang Naming?

Run "/install golang-naming" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Golang Naming free?

Yes, Golang Naming is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Golang Naming support?

Golang Naming is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Golang Naming?

It is built and maintained by Samuel Berthe (@samber); the current version is v1.1.1.

💬 Comments