go-conventions
Skill1 starsChanged 3 months agoMITView on GitHub
Use when writing, reviewing, or refactoring Go code — naming conventions, receiver naming, error wrapping, interface design, goroutine safety, and common pitfalls (goroutine leaks, defer-in-loop, nil map writes).
4 other projects use a version of this.
Adopted by
Most recently taken up by
- wtsi-hgi/agentskillstheir own version, first seen Oct 4, 2026
- techmefr/mentistheir own version, first seen Sep 11, 2026
- hashicorp/terraform-provider-awstheir own version, first seen May 14, 2026
- hairglasses-studio/mcpkittheir own version, first seen Apr 9, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- hashicorp/terraform-provider-aws★ 11ksame name
- wtsi-hgi/agentskills★ 1same name
- hairglasses-studio/mcpkit★ 0same name
- techmefr/mentis★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository77 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/accessibility.mdcCursor rule
- .cursor/rules/agentharness-router.mdcCursor rule
- .cursor/rules/agentic-loops.mdcCursor rule
- .cursor/rules/api-design.mdcCursor rule
- .cursor/rules/audit-review-followup.mdcCursor rule
- .cursor/rules/big-work-plan-review.mdcCursor rule
- .cursor/rules/branching.mdcCursor rule
- .cursor/rules/clean-architecture.mdcCursor rule
- .cursor/rules/code-review-api.mdcCursor rule
- .cursor/rules/code-review-db.mdcCursor rule
- .cursor/rules/code-review.mdcCursor rule
- .cursor/rules/code-review-ui.mdcCursor rule
- .cursor/rules/committing.mdcCursor rule
- .cursor/rules/database-conventions.mdcCursor rule
- .cursor/rules/dependency-audit.mdcCursor rule
- .cursor/rules/dependency-injection.mdcCursor rule
- .cursor/rules/design-patterns.mdcCursor rule
- .cursor/rules/docker-conventions.mdcCursor rule
- .cursor/rules/error-handling.mdcCursor rule
- .cursor/rules/file-placement-policy.mdcCursor rule
- .cursor/rules/github-issue-triage.mdcCursor rule
- .cursor/rules/go-conventions.mdcCursor rule
- .cursor/rules/harness-feedback.mdcCursor rule
- .cursor/rules/logging.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/mutation-testing.mdcCursor rule
- .cursor/rules/performance-profiling.mdcCursor rule
- .cursor/rules/planning-with-files.mdcCursor rule
- .cursor/rules/port-agent-config.mdcCursor rule
- .cursor/rules/project-bootstrap.mdcCursor rule
- .cursor/rules/python-conventions.mdcCursor rule
- .cursor/rules/react-best-practices.mdcCursor rule
- .cursor/rules/refactoring.mdcCursor rule
- .cursor/rules/requirements-clarification.mdcCursor rule
- .cursor/rules/security-review.mdcCursor rule
- .cursor/rules/solid-principles.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/typescript-conventions.mdcCursor rule
- accessibilitySkill
- agentic-loopsSkill
- api-designSkill
- audit-review-followupSkill
- big-work-plan-reviewSkill
- branchingSkill
- clean-architectureSkill
- code-review-apiSkill
- code-review-dbSkill
- code-reviewSkill
- code-review-uiSkill
- committingSkill
- database-conventionsSkill
- dependency-auditSkill
- dependency-injectionSkill
- design-patternsSkill
- docker-conventionsSkill
- error-handlingSkill
- file-placement-policySkill
- The first 60 shown.
The file
Files
Go Conventions
This file is self-contained for day-to-day use. Deeper reference (needs
the full harness checkout): languages/go/CONVENTIONS.md (full examples
including godoc comments, context-first concurrency, and table-driven
tests).
Naming
- Unexported:
camelCase. Exported:PascalCase. - Interfaces: singular, behavior-describing name (
Reader,Storer,UserRepository— notIUserRepository). - Error sentinels:
Errprefix (ErrNotFound,ErrTimeout). - Receiver: one or two letters, the type's initials (
u *User, notuser *User). Keep consistent across all methods of a type.
Errors: wrap with context, return early
// Wrap to preserve the stack — don't swallow context
if err != nil {
return fmt.Errorf("getUserByID %q: %w", id, err)
}
// Return early — avoid deep nesting
func process(ctx context.Context, id string) error {
user, err := repo.Find(ctx, id)
if err != nil {
return fmt.Errorf("process: find user: %w", err)
}
// ... rest of the logic at the same indent level
}Interfaces: define at the point of use
Declare the interface in the package that uses it, not the package that
implements it. A concrete type's package need not know about the
interface — io.Reader doesn't live in the os package, and
UserRepository should live in the handler/service that calls it, not
in the postgres package that provides one.
Pitfalls to catch in review
// Goroutine leak — if nothing reads from result, the goroutine
// blocks forever on the send and is never garbage-collected
go func() {
result <- compute() // will block if nobody reads result
}()
// Defer in loop executes at *function* return, not loop iteration
for _, f := range files {
defer f.Close() // WRONG — all defers run when function exits
// RIGHT: use an inner function or close explicitly at end of loop
}
// Write to a nil map panics at runtime
var m map[string]int
m["key"] = 1 // panic: assignment to entry in nil map
// RIGHT: initialize first (use = not :=, m is already declared)
m = make(map[string]int)
// Shadowing err in short variable declaration inside a block
result, err := doSomething()
if err == nil {
data, err := doAnotherThing() // this `err` is a new variable
_ = data
}
// The outer `err` is unchanged; use `=` for the inner one if intendedExport documentation
Exported symbols need a // comment starting with the symbol name:
// User represents an authenticated user in the system.
type User struct { /* ... */ }
// FindByID retrieves a user by their unique identifier.
// Returns ErrNotFound if no user with that ID exists.
func (r *postgresRepo) FindByID(ctx context.Context, id string) (*User, error) { }Testing
Table-driven tests with t.Run subtests, _test package for black-box
tests. See patterns/testing/TDD.md for the broader methodology — this
skill covers Go-specific structure only.
Formatting & tooling
gofmt (or goimports) is non-negotiable — all Go code must be
formatted. Use golangci-lint for static analysis. go vet is run
automatically by go test.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

