Code Conventions
Go
- Go 1.26+
- gofmt / gofumpt / goimports / gci
- 120 characters per line
- Guard clauses instead of nested ifs
- Naming:
camelCasefor private,PascalCasefor exported
Errors
Use LLMError for LLM-visible errors:
go
type LLMError struct {
Code string `json:"code"`
Message string `json:"message"`
}Error codes:
validation_failed— invalid parametersnot_found— resource not foundrate_limit— rate limit exceededinvoke_error— API call error
Interfaces
- Small interfaces (1-3 methods)
- Interface composition
- Functional options for configuration
Testing
- Table-driven tests
- Test helpers (
newTestService(),seedTestData()) - Mocks via
go.uber.org/mock - 80%+ coverage for core packages
Configuration
- YAML format
- Cascade: global → spec → collection
- Validation via
go-playground/validator - Environment variables via
$(VAR)