- Follow Effective Go and Go Code Review Comments guidelines.
- Handle every error return. Wrap errors with context:
fmt.Errorf("operation failed: %w", err). - Linting: a meta-linter (e.g., golangci-lint) with strict config (enable
govet,staticcheck,errcheck, and a security analyzer). Format withgofmt/goimports. - Security:
govulncheckfor CVE scanning, a SAST tool for static analysis. Run both in CI. - Testing: table-driven tests with
t.Run()and the stdlibtestingpackage. Uset.Parallel()where safe. An assertion library (e.g., testify) is optional. Coverage withgo test -coverprofile. - Naming: use short, descriptive names. Receivers are 1-2 letters. Exported names are descriptive.
- Prefer composition over inheritance. Use interfaces for abstraction (accept interfaces, return structs).
- Keep packages small and focused. Avoid package-level state and
init()functions. - Use
context.Contextas first parameter for cancelable operations. Never store contexts in structs. - Error types: use
errors.Is()/errors.As()for comparison. Define sentinel errors witherrors.New(). - Modules: use Go modules. Commit
go.sum. Use semantic version tags. Prefer stdlib over third-party when reasonable. - Concurrency: prefer channels over mutexes. Use
sync.WaitGroupfor fan-out. Guard shared state. - Benchmarking: use
testing.Bbenchmarks. Profile withgo tool pprof. Usebenchstatfor comparison.
Go Conventions
Go code conventions covering Effective Go, error wrapping, golangci-lint, govulncheck, table-driven tests, interfaces, context usage, modules, and concurrency. Load when writing or reviewing Go code.
Go Conventions by goldziher · 82f7ee5
npx skillmds@latest add goldziher/go-conventions File contents
---name: go-conventionsdescription: Go code conventions covering Effective Go, error wrapping, golangci-lint, govulncheck, table-driven tests, interfaces, context usage, modules, and concurrency. Load when writing or reviewing Go code.---- Follow Effective Go and Go Code Review Comments guidelines.- Handle every error return. Wrap errors with context: `fmt.Errorf("operation failed: %w", err)`.- Linting: a meta-linter (e.g., golangci-lint) with strict config (enable `govet`, `staticcheck`, `errcheck`, and a security analyzer). Format with `gofmt`/`goimports`.- Security: `govulncheck` for CVE scanning, a SAST tool for static analysis. Run both in CI.- Testing: table-driven tests with `t.Run()` and the stdlib `testing` package. Use `t.Parallel()` where safe. An assertion library (e.g., testify) is optional. Coverage with `go test -coverprofile`.- Naming: use short, descriptive names. Receivers are 1-2 letters. Exported names are descriptive.- Prefer composition over inheritance. Use interfaces for abstraction (accept interfaces, return structs).- Keep packages small and focused. Avoid package-level state and `init()` functions.- Use `context.Context` as first parameter for cancelable operations. Never store contexts in structs.- Error types: use `errors.Is()`/`errors.As()` for comparison. Define sentinel errors with `errors.New()`.- Modules: use Go modules. Commit `go.sum`. Use semantic version tags. Prefer stdlib over third-party when reasonable.- Concurrency: prefer channels over mutexes. Use `sync.WaitGroup` for fan-out. Guard shared state.- Benchmarking: use `testing.B` benchmarks. Profile with `go tool pprof`. Use `benchstat` for comparison.
goldziher/ai-rulez/tree/main/internal/builtins/languages/go/skills/go-conventions commit 82f7ee5435
Frequently asked questions
Run npx skillmds@latest add goldziher/go-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Go code conventions covering Effective Go, error wrapping, golangci-lint, govulncheck, table-driven tests, interfaces, context usage, modules, and concurrency. Load when writing or reviewing Go code. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
goldziher (@goldziher) published this skill. Their other Agent Skills are listed on their SkillMD profile.