Write Go Code
Core Principles
- Clarity over cleverness - Code should be obvious to readers
- Simplicity - Accomplish goals in the most straightforward way
- Consistency - Match surrounding code and project conventions
- Minimal indentation - Handle errors early, keep happy path unindented
Workflow
- Run automated checks (
make lint,make fmtorgofmt,goimports) - Review against essential checklist:
references/essential/checklist.md - For specific questions, consult:
references/comprehensive/{topic}.md - When creating or editing Cobra root commands, consult:
references/comprehensive/cobra.md
Reference Navigation
Quick reviews (default):
references/essential/checklist.md- Condensed, actionable rules
Deep dives by topic:
references/comprehensive/naming.md- Package names, identifiers, receiversreferences/comprehensive/errors.md- Error handling, panic/recoverreferences/comprehensive/concurrency.md- Goroutines, channels, contextreferences/comprehensive/testing.md- Test quality and patternsreferences/comprehensive/code-organization.md- Imports, packages, structurereferences/comprehensive/data-types.md- new vs make, slices, mapsreferences/comprehensive/functions.md- Multiple returns, deferreferences/comprehensive/interfaces.md- Embedding, type assertionsreferences/comprehensive/makefile-conventions.md- Required CI targets, fmt vs formatreferences/comprehensive/cobra.md- Cobra root command usage templates