cxuu avatar

Go Error Handling

Handles the full spectrum of Go error patterns: choosing between sentinel errors, custom types, and fmt.Errorf wrapping (%w vs %v), structuring error flow with early returns, and deciding whether to log or return (never both). Ships with a linter script that catches common anti-patterns like string comparison on err.Error() and log-and-return violations. The references cover wrapping strategy at package boundaries, when to escalate from simple errors.New to typed errors, and the handle-once pattern. Requires Go 1.13+ for errors.Is/As. Built from Google and Uber style guides, so you get opinionated guidance on things like error string capitalization and avoiding in-band error values.

skills.sh installs
1.3K
GitHub stars
193
last updated
Aug 21, 2026

Install

$ npx -y skills add cxuu/golang-skills --skill go-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Files

Go Error Handling

Compatibility: errors.Is, errors.As, and %w wrapping require Go 1.13+; structured logging examples may use log/slog from Go 1.21+.

Resource Routing

  • scripts/check-errors.sh - Run when checking string-based error matching, bare error propagation, and log-and-return patterns.
  • scripts/check-errors-ast.go - Implementation helper invoked by check-errors.sh; patch this when changing error-flow analysis behavior.
  • references/ERROR-FLOW.md - Read when deciding where to handle, wrap, log, or return errors.
  • references/ERROR-TYPES.md - Read when choosing sentinel errors, typed errors, or opaque errors.
  • references/WRAPPING.md - Read when choosing %w versus %v or crossing package boundaries.

In Go, errors are values — they are created by code and consumed by code.

Choosing an Error Strategy

Sponsors

Details

Repository
github.com/cxuu/golang-skills
Categories
Documentation, Debugging, Go
First seen
May 16, 2026

More from cxuu/golang-skills

All 20
1jezweb avatargithub-releasejezweb/claude-skillsPrepare and publish GitHub releases. Sanitizes code for public release (secrets scan, personal artifacts, LICENSE/README validation), creates version tags, and 1.3Kskills.sh installs
2neolabhq avatarbrainstormneolabhq/context-engineering-kitUse when creating or developing, before writing code or implementation plans - refines rough ideas into fully-formed designs through collaborative questioning, 1.3Kskills.sh installs
3cap-go avatarcapacitor-deep-linkingcap-go/capgo-skillsComplete guide to implementing deep links and universal links in Capacitor apps. Covers iOS Universal Links, Android App Links, custom URL schemes, and navigati1.3Kskills.sh installs
4cxuu avatargo-concurrencycxuu/golang-skillsUse when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing work, fixing data races, or protec1.3Kskills.sh installs
5cap-go avatarios-android-logscap-go/capgo-skillsGuide to accessing device logs on iOS and Android for Capacitor apps. Covers command-line tools, GUI applications, filtering, and real-time streaming. Use this 1.3Kskills.sh installs
6tursodatabase avatarindex-knowledgetursodatabase/tursoGenerate hierarchical AGENTS.md knowledge base for a codebase. Creates root + complexity-scored subdirectory documentation.1.3Kskills.sh installs