What problem does it solve?
Go developers often build software that fails silently or crashes due to improper error handling. This skill provides proven patterns for returning errors, wrapping with %w, designing sentinel and structured error types, and enforcing consistent error messaging and logging to improve reliability and debuggability.
Core Features & Use Cases
- Returns and propagates errors correctly: Standardizes error return values and the last return parameter.
- Wraps context with %w for error chains: Preserves error information while adding context for better diagnosis.
- Defines and uses structured errors and sentinel values: Enables precise error matching with errors.Is and errors.As.
- Guidelines for error strings, handling, and logging: Reduces noise and improves maintainability.
- Use Case: When building Go services that call I/O, network, or filesystem APIs and need reliable error handling across layers.
Quick Start
Implement robust error handling in your Go code using the patterns described above.