golang-samber-oops

Create structured context-rich errors with samber/oops in Go applications.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/tamago0224/kuroshio-mta --skill golang-samber-oops-tamago0224
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/tamago0224/kuroshio-mta/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/tamago0224/kuroshio-mta --skill golang-samber-oops-tamago0224

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go developers often struggle with unstructured errors that lack context, making debugging and observability difficult. This skill introduces samber/oops to turn errors into rich, queryable data with stack traces, codes, and user‑facing messages.

Core Features & Use Cases

  • Fluent Builder Chain: Construct errors with .In(), .Tags(), .Code(), .User(), .With() and more.
  • Stack Traces & Error Codes: Automatic capture of call stacks and machine‑readable identifiers.
  • Public vs Technical Messages: Separate user‑safe .Public() messages from technical details.
  • Panic Recovery: Convert panics to structured errors using .Recover() or .Recoverf().
  • Context Propagation: Store builders in context.Context with oops.WithBuilder / oops.FromContext.
  • Logger Integration: Seamlessly attach error data to slog, zerolog, logrus, etc.

Quick Start

Generate a structured oops error by specifying the domain, error code, relevant attributes, and a static message.

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 stack traces and context to Go errors?

Structured Go error handling with samber/oops lets you wrap errors using a fluent builder chain with .In(), .Tags(), and .Code() methods, attaching domain context, stack traces, and attributes for better observability.

What's the best way to separate public and technical error messages in Go?

The best way to separate public and technical messages in Go is using samber/oops, which provides .Public() for user-safe messages while keeping technical details and stack traces internal for logging and debugging.

How do I recover from panics and convert them to structured errors in Go?

You can recover from panics and convert them to structured errors in Go by applying samber/oops .Recover() or .Recoverf() methods, which capture the panic and wrap it with stack traces and contextual attributes.

Can I propagate error builders through context in Go applications?

Yes, you can propagate error builders through context in Go applications by storing and retrieving samber/oops builders using oops.WithBuilder and oops.FromContext, allowing context-rich error wrapping across HTTP handlers and service layers.

Does structured error handling in Go work with slog and zerolog?

Structured error handling in Go integrates seamlessly with slog, zerolog, and logrus, allowing you to attach error data like codes, tags, and stack traces directly to your structured logging output for improved observability.

Do I need the Go toolchain and samber/oops package to build structured errors?

Yes, you need the Go toolchain and the samber/oops package installed in your Go codebase to build and wrap errors with attributes, stack traces, and public messages across your application layers.