z-go-errors

Installation
SKILL.md

Go errors

Core rules

  1. Check every error — never discard with _.
  2. Wrap with context: fmt.Errorf("create user: %w", err) — short prefix, lowercase, no period.
  3. Translate errors at transport boundaries — %v removes wrapping but does not sanitize the message. Return stable public errors; retain internal causes for one safe log.
  4. Inspect via errors.Is / errors.As — never == on wrapped errors or bare type assertions.
  5. Handle exactly once — log OR return, never both (see Single Handling below).
  6. Panic only for truly unrecoverable states — programmer errors, broken invariants; never for expected conditions.

Wrapping and inspection

// wrap
return fmt.Errorf("fetch user %s: %w", id, err)

// sentinel check — works through the chain
if errors.Is(err, ErrNotFound) { ... }
Installs
15
First Seen
Jul 2, 2026