Go Error Handling

Guides Go error handling as values — wrap with fmt.Errorf and %w to preserve the chain, inspect with errors.Is (sentinel) and errors.As / errors.AsType (typed) instead of string-matching, choose sentinel vs custom error types and when they become API, combine with errors.Join, write lowercase un-punctuated messages, handle each error exactly once, and decorate or close-with-error via named returns and defer. Auto-invokes when writing or editing error returns, fmt.Errorf, errors.Is/As, custom error types, or on "handle this error" / "why is this error not matching" requests. The depth behind the policy root's "errors are values, never silently discarded."

ctoth d279f60 3 files · 27.6 KB Updated

File contents

ctoth/golang-skills-plugin/tree/main/plugins/golang/skills/go-error-handling commit d279f6083a

Frequently asked questions

npx skillmds@latest add ctoth/go-error-handling