Download for macOS
Skill

golang-error-handling

@samber 40k installs Trending #405 on Skills.Sh Updated 2026-08-01

Idiomatic Golang error handling — creation, wrapping with %w, errors.Is/As, errors.Join, custom error types, sentinel errors, panic/recover, the single handling rule, structured logging with slog, HTTP request logging middleware, and samber/oops for production errors. Built to make logs usable at scale with log aggregation 3rd-party tools. Apply when creating, wrapping, inspecting, or logging errors in Go code. For samber/oops specifics → See `samber/cc-skills-golang@golang-samber-oops` skill; for slog handler ecosystem → See `samber/cc-skills-golang@golang-samber-slog` skill.

agentagent-skillsaiantigravityclaudeclaude-codecodecodex

Install

git clone https://github.com/samber/cc-skills-golang /tmp/cc-skills-golang && ln -s /tmp/cc-skills-golang/skills/golang-error-handling ~/.claude/skills/golang-error-handling

From README

Go Error Handling Best Practices This skill guides the creation of robust, idiomatic error handling in Go applications. Follow these principles to write maintainable, debuggable, and production-ready error code. Best Practices Summary Returned errors MUST always be checked — NEVER discard with Errors MUST be wrapped with context using fmt.Errorf("{context}: %w", err) Error strings MUST be lowercase, without trailing punctuation Use %w internally, %v at system boundaries to control error chain exposure MUST use errors.Is for sentinel matching and errors.As/errors.AsType for typed chain inspection instead of direct comparison or bare type assertions. For Go 1.26+, prefer errors.AsTypeT when T implements error; use errors.As(err, &target) for Go <1.26 or for non-error interface targets.