What problem does it solve?
Prevents inconsistent, fragile, and hard-to-maintain Go code by codifying a set of conventions and patterns that reduce bugs, improve readability, and streamline reviews. It centralizes expectations for error handling, concurrency, logging, testing, and project structure so teams produce predictable, maintainable services.
Core Features & Use Cases
- Error handling: Require contextual error wrapping (e.g., fmt.Errorf with %w) to preserve causality and provide actionable messages.
- Application structure: Keep main.go thin (config → deps → wiring → server) and place non-public code under internal/.
- Context & concurrency: Enforce ctx context.Context as the first parameter for I/O operations and proper defer-based cleanup.
- Logging & testing: Use structured slog logging and table-driven tests with testify/assert.
- Use Case: Use when implementing or reviewing Go services (alt-backend, auth-hub, pre-processor, search-indexer, mq-hub, altctl) to ensure consistent, production-ready code.
Quick Start
Review the provided Go file and apply the rules from docs/best_practices/go.md to produce edits and suggestions that enforce error wrapping, context usage, structured logging, table-driven tests, and proper package placement.