go-best-practices
SKILL.md
Go Best Practices
This skill guides high-level architectural decisions and deep code reviews.
Core Mandates
- Architecture:
- NO
pkg/: Do not create or recommend apkg/directory. It is an anti-pattern. - Flat by Default: Encourage flat package structures unless complexity demands otherwise.
- Standard Layout: Use
internal/for private logic andcmd/for multiple binaries.
- NO
- Code Quality:
- Check First: Always consult
references/style_cheatsheet.mdbefore making style edits. - Review Checklist: Use
references/senior_review_checklist.mdfor major PRs. - Modern Go: Prefer generic functions (
func F[T any]) overinterface{}.
- Check First: Always consult
- Concurrency:
- Lifecycle: Every goroutine must have a clear exit condition (Context, WaitGroup).
- Hygiene: Use
errgroupfor parallel tasks.
Workflow
1. Audit & Analyze
- Inspect Layout: Does the project use
pkg/? Advise moving tointernal/or root. - Review Style: Check against
style_cheatsheet.md.- Are errors handled explicitly?
- Are contexts passed first?
- Are mutexes copied? (Use
go vet).
2. Refactor
- Plan: Identify the specific architectural change (e.g., "Extract interface for decoupling").
- Execute: Apply changes incrementally.
- Verify: run
go build ./...,go test ./..., andgolangci-lint runafter every significant edit.
3. Review
- Checklist: Run through
senior_review_checklist.md. - Feedback: Provide actionable, cited feedback.
4. Specialized Domains
- Web Services: Consult
references/http_services.mdfor routing, middleware, and observability patterns. - Complex Testing: Use
references/advanced_testing.mdfor fuzzing, benchmarks, and integration tests. - Game Development: Refer to
references/ebitengine_docs.mdfor Ebitengine-specific patterns. - Idioms: When in doubt, check
references/go_proverbs.md. - Linting: Refer to
references/linting.mdfor tool configuration and best practices.
References
references/style_cheatsheet.md: Condensed critical style rules.references/senior_review_checklist.md: High-level quality criteria.references/project_layout.md: Standard module layout guide.references/architectural_decisions.md: Template for ADRs.references/http_services.md: Best practices for HTTP servers.references/advanced_testing.md: Fuzzing and benchmarking guide.references/ebitengine_docs.md: Ebitengine reference.references/go_proverbs.md: Core Go philosophy.references/linting.md: Linting tools and guidelines.
Weekly Installs
4
Repository
danicat/skillsGitHub Stars
3
First Seen
10 days ago
Security Audits
Installed on
opencode4
gemini-cli4
claude-code4
github-copilot4
amp4
cline4