About
This skill provides Go style guidance based on Effective Go and Go Code Review Comments for code review and writing tasks. It enforces formatting rules, naming conventions, import ordering, and other idiomatic patterns. Use it specifically for style and formatting checks, not for architecture or performance concerns.
Quick Install
Claude Code
Recommendednpx skills add eduardo-sl/go-agent-skills -a claude-code/plugin add https://github.com/eduardo-sl/go-agent-skillsgit clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-coding-standardsCopy and paste this command in Claude Code to install this skill
Documentation
Go Coding Standards
Idiomatic Go conventions grounded in Effective Go, Go Code Review Comments, and production-proven idioms.
All code MUST pass goimports, go vet, and staticcheck (or golangci-lint run) without errors.
1. Import Ordering
Group imports in this order, separated by blank lines:
import (
// 1. Standard library
"context"
"fmt"
"net/http"
// 2. External packages
"github.com/gorilla/mux"
"log/slog"
// 3. Internal/project packages
"github.com/myorg/myproject/internal/service"
)
NEVER use dot imports. Use aliasing only to resolve conflicts.
2. Naming Conventions
Packages
- Short, lowercase, single-word names. No underscores, no camelCase.
- Name should describe what the package provides, not what it contains.
- Avoid generic names:
util,common,helpers,misc,base.
Functions & Methods
- MixedCaps (exported) or mixedCaps (unexported). No underscores except in test files.
- Getters: use
Name(), NOTGetName(). Setters: useSetName(). - Constructors:
NewFoo()returns*Foo. If only one type in package:New().
Variables
- Short names in tight scopes:
i,n,err,ctx. - Descriptive names for wider scopes:
userCount,retryTimeout. - Prefix unexported package-level globals with
_:var _defaultTimeout = 5 * time.Second. - Do NOT shadow built-in identifiers (
error,len,cap,new,make,close).
Interfaces
- Single-method interfaces: method name +
-ersuffix (Reader,Writer,Closer). - Define interfaces where they are consumed, not where they are implemented.
3. Variable Declarations
Top-level
Use var for top-level declarations. Do NOT specify type when it matches the expression:
// ✅ Good
var _defaultPort = 8080
var _logger = slog.Default()
// ❌ Bad — redundant type
var _defaultPort int = 8080
Local
- Prefer
:=for local variables. - Use
varonly when zero-value initialization is intentional and meaningful.
// ✅ Good — zero value is meaningful
var buf bytes.Buffer
// ✅ Good — short declaration
name := getUserName()
4. Struct Initialization
ALWAYS use field names. Never rely on positional initialization:
// ✅ Good
user := User{
Name: "Alice",
Email: "[email protected]",
Age: 30,
}
// ❌ Bad — positional, breaks on field reordering
user := User{"Alice", "[email protected]", 30}
Omit zero-value fields unless clarity requires them:
// ✅ Good — zero values omitted
user := User{
Name: "Alice",
}
5. Reduce Nesting
Handle errors and special cases first with early returns. Reduce indentation levels:
// ✅ Good — early return
func process(data []Item) error {
for _, v := range data {
if !v.IsValid() {
log.Printf("invalid item: %v", v)
continue
}
if err := v.Process(); err != nil {
return err
}
v.Send()
}
return nil
}
Eliminate unnecessary else blocks:
// ✅ Good
a := 10
if condition {
a = 20
}
// ❌ Bad
var a int
if condition {
a = 20
} else {
a = 10
}
6. Grouping and Ordering
Group related declarations:
const (
_defaultPort = 8080
_defaultTimeout = 30 * time.Second
)
var (
_validTypes = map[string]bool{"json": true, "xml": true}
_defaultUser = User{Name: "guest"}
)
Function ordering within a file:
- Constants and variables
New()/ constructor functions- Exported methods (sorted by importance, not alphabetically)
- Unexported methods
- Helper functions
Receiver methods should appear immediately after the type declaration.
7. Line Length
Soft limit of 99 characters. Break long function signatures:
func (s *Store) CreateUser(
ctx context.Context,
name string,
email string,
opts ...CreateOption,
) (*User, error) {
8. Defer Usage
Use defer for cleanup. It makes intent clear at the point of acquisition:
mu.Lock()
defer mu.Unlock()
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
9. Enums
Start enums at 1 (or use explicit sentinel) so zero-value signals "unset":
type Status int
const (
StatusUnknown Status = iota
StatusActive
StatusInactive
)
10. Use time Package Properly
- Use
time.Durationfor durations, NOT raw integers. - Use
time.Timefor instants. Usetime.Since(start)instead oftime.Now().Sub(start). - External APIs: accept
intorfloat64and convert internally.
// ✅ Good
func poll(interval time.Duration) { ... }
poll(10 * time.Second)
// ❌ Bad
func poll(intervalSecs int) { ... }
poll(10)
Verification Checklist
Before considering code complete:
goimportsruns cleango vet ./...passesgolangci-lint runpasses (if configured)- No shadowed built-in identifiers
- All imports properly grouped and ordered
- Struct initializations use field names
- No unnecessary nesting or else blocks
GitHub Repository
Frequently asked questions
What is the go-coding-standards skill?
go-coding-standards is a Claude Skill by eduardo-sl. Skills package instructions and resources that Claude loads on demand, so Claude can perform go-coding-standards-related tasks without extra prompting.
How do I install go-coding-standards?
Use the install commands on this page: add go-coding-standards to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does go-coding-standards belong to?
go-coding-standards is in the Development category, tagged general.
Is go-coding-standards free to use?
Yes. go-coding-standards is listed on AIMCP and free to install.
Related Skills
qmd is a local search and indexing CLI tool that enables developers to index and search through local files using hybrid search combining BM25, vector embeddings, and reranking. It supports both command-line usage and MCP (Model Context Protocol) mode for integration with Claude. The tool uses Ollama for embeddings and stores indexes locally, making it ideal for searching documentation or codebases directly from the terminal.
This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.
The mcporter skill enables developers to manage and call Model Context Protocol (MCP) servers directly from Claude. It provides commands to list available servers, call their tools with arguments, and handle authentication and daemon lifecycle. Use this skill for integrating and testing MCP server functionality in your development workflow.
This skill deploys and orchestrates Vertex AI ADK agents using A2A protocol, managing AgentCard discovery, task submission, and supporting tools like Code Execution Sandbox and Memory Bank. It enables building multi-agent systems with sequential, parallel, or loop orchestration patterns in Python, Java, or Go. Use it when asked to deploy ADK agents or orchestrate agent workflows on Google Cloud.
