golang-samber-oops

Implements structured error handling in Go using the samber/oops builder pattern.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-samber-oops-verifiedorganic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/VerifiedOrganic/onboard/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-samber-oops-verifiedorganic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/samber/oops, and includes references (resource) components.

What problem does it solve? Standard Go errors lack context: you see "connection failed" but not which user triggered it, what query was running, or the full call stack. This Skill guides AI coding agents to write structured, diagnosable error handling with samber/oops so on-call engineers can diagnose failures without asking the developer. ## Core Features & Use Cases - Fluent error builders: Chain .In(), .Tags(), .Code(), .With(), .User(), and .Tenant() to attach domain, categorization, machine-readable codes, and structured attributes to every error. - Low-cardinality messages: Keeps variable data in .With() attributes instead of interpolating it into message strings, so APM tools like Datadog, Loki, and Sentry can group errors correctly. - Panic recovery and context propagation: Converts panics to structured errors with oops.Recover() at goroutine boundaries and propagates pre-configured builders through Go contexts via oops.WithBuilder/oops.FromContext. - Use Case: In a three-layer Go service (handler, service, repository), wrap errors at each layer boundary with layer-specific context so a single error reaching the top carries the query, user ID, trace ID, and full stack trace. ## Quick Start Ask the agent to refactor the error handling in your Go service to use samber/oops with structured attributes, error codes, and public user-facing messages.

Frequently Asked Questions about golang-samber-oops

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

FAQPage Schema
How do I add structured context to Go errors with samber/oops?▼

Use the fluent builder pattern: chain methods like oops.In("domain").With("key", value).Wrapf(err, "message") to attach domain, attributes, and codes. Variable data goes in .With() attributes, not the message string, so APM tools can group errors.

samber/oops vs standard Go errors: what is the difference?▼

Standard Go errors carry only a message string, while samber/oops adds structured attributes, stack traces, machine-readable codes, public user-safe messages, and trace IDs. It is a drop-in replacement since OopsError implements the standard error interface.

Does oops.Wrap need a nil check before wrapping an error?▼

No. oops.Wrap and oops.Wrapf return nil when the input error is nil, so you can write return oops.Wrapf(err, "operation failed") directly without an if err != nil block.

How do I convert panics to errors in Go goroutines?▼

Use oops.Recover() at goroutine boundaries instead of raw defer/recover. Pass the risky operation as a function to .Recover() on a builder with .In(), .Code(), and .With() context, using a named error return value.

How do I show user-friendly messages while logging technical details?▼

Set a user-safe message with .Public("Not enough items in stock.") separately from the technical message in .Errorf(). Retrieve it at the HTTP layer with oops.GetPublic(err, "fallback message").

How do I configure samber/oops stack trace depth and timezone?▼

Set the global variables oops.StackTraceMaxDepth, oops.Local (with time.LoadLocation), and oops.SourceFragmentsHidden at init time. No wrapper or post-processing of errors is needed.