go-error-management

Review Go error handling for panic usage, wrapping, and error checks.

15|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/v0lka/skills --skill go-error-management
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-error-management
Source: https://github.com/v0lka/skills/tree/main/development/idiomatic-go/go-error-management
Command: npx skills add https://github.com/v0lka/skills --skill go-error-management

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about go-error-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I properly wrap and inspect errors in Go?

Wrap errors with %w to preserve originals and transform them with %v to hide internals. Inspect wrapped errors reliably using errors.Is for sentinel values and errors.As for typed errors to ensure robust checks across API boundaries.

What is the best way to handle defer errors in Go without double-handling?

Defer error handling in Go requires reporting or properly propagating errors safely. Ensure errors are handled exactly once by avoiding silent ignores and managing defer-related errors without duplicate processing, maintaining code robustness.

When should I use panic versus return errors in Go?

Use panic in Go for truly exceptional, unrecoverable failures rather than routine control flow. Avoid misused panics by returning errors normally, ensuring your error handling remains robust and maintainable across package boundaries.

How do I refactor Go code to use errors.Is and errors.As correctly?

Refactor Go code by replacing direct error comparisons with errors.Is for sentinel checks and errors.As for type assertions. Apply proper wrapping to preserve error context across API boundaries and callers.

Why are my Go errors silently ignored or handled multiple times?

Go errors get silently ignored or double-handled due to inconsistent checks and improper wrapping. Enforce exactly-once handling by using errors.Is, errors.As, and proper wrapping to avoid silent ignores and double-processing.

Does this approach to Go error handling work for library refactoring?

Yes, this approach refactors Go libraries to provide stable, inspectable errors across API boundaries. It enforces guidance for wrapping versus transforming errors so callers receive consistent, robust error responses.