golang-samber-oops

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

Updated May 9, 2026
One-click install
npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-oops-luminavault
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/LuminaVault/LuminaVaultShared/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-oops-luminavault

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 agents to write samber/oops error handling that attaches structured attributes, stack traces, error codes, and user-safe messages to every error. ## Core Features & Use Cases - Fluent error builders: Chain .In(), .Tags(), .Code(), .With(), .User(), and .Tenant() to attach domain, categorization, and identity context to errors. - Low-cardinality messages: Keep variable data in .With() attributes instead of interpolating IDs into message strings, so APM tools like Datadog, Loki, and Sentry group errors correctly. - Panic recovery and context propagation: Convert panics to structured errors with .Recover() at goroutine boundaries, and propagate pre-configured builders through Go contexts with 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 logged error shows the HTTP request, the operation, and the failing SQL query. ## Quick Start Refactor my Go service's error handling 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 .In("domain"), .Tags("database"), .Code("network_failure"), and .With("key", value), then terminate with .Errorf(), .Wrap(err), or .Wrapf(err, msg). Attributes travel with the error through the call stack.

How does samber/oops compare to standard Go error handling?▼

samber/oops is a drop-in replacement that adds structured attributes, automatic stack traces, machine-readable codes, and public messages that stdlib errors lack. Unlike adding slog attributes at the log site, oops attributes travel with the error through every layer.

Why should error messages avoid variable interpolation in samber/oops?▼

Interpolating IDs into Errorf messages creates high-cardinality strings that break error grouping in APM tools like Datadog, Loki, and Sentry. Put variable data in .With() attributes and keep the message string static.

Does samber/oops work with slog, zerolog, and logrus?▼

Yes, samber/oops works with any logger. Errors implement the standard error interface, support JSON marshaling, and expose methods like Code(), Domain(), Tags(), Context(), and Stacktrace() for structured log fields.

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

Use oops.Recover() or the builder's .Recover(fn) method at goroutine boundaries with a named error return value. It converts panics into structured errors carrying your configured domain, code, hint, and attributes.

When should I not use oops assertions in Go?▼

Assertions like oops.Assertf panic and should be rare in Go. Use them only for truly impossible states that indicate a bug, and always wrap them in oops.Recover() so the panic becomes a structured error.