What problem does it solve?
Go projects often suffer from brittle error handling due to misused panics, improper wrapping or transforming of errors, and inconsistent checks with errors.Is and errors.As. This skill guides developers to write robust, maintainable error-handling code by clarifying when to panic, how to wrap vs transform errors, how to inspect errors reliably, ensure errors are handled exactly once, avoid silent ignores, and handle defer-related errors safely.
Core Features & Use Cases
- Guidelines for error wrapping and inspection: choose between wrapping %w and transforming %v to preserve or hide internals, and use errors.Is and errors.As for robust error inspection.
- Safe defer error handling: ensure defer errors are reported or properly propagated without double-handling.
- Use Case: refactor a Go library to provide stable, inspectable errors across API boundaries and callers.
Quick Start
Audit an existing Go function and rewrite its error handling to use errors.Is and errors.As with proper wrapping.