golang-samber-oops

Attach structured context, codes, and stack traces to Go errors using samber/oops.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-samber-oops-nrmnqdds
Or copy as Structured Prompt for Agentโ–ผ
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/nrmnqdds/gomaluum/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-samber-oops-nrmnqdds

SYSTEM DOCUMENTATION & REQUIREMENTS

๐Ÿ’ก This Skill includes references (resource) components.

What problem does it solve?

samber/oops provides structured error handling for Go by attaching context, stack traces, machine-readable codes, and public messages to errors, improving diagnosability and observability.

Core Features & Use Cases

  • Fluent builder pattern for errors, e.g., In, With, Code, Public, Wrapf, Recover.
  • Context propagation across layers using WithBuilder and FromContext in HTTP handlers, services, and repositories.
  • Public vs technical messages with recoverable panics and structured logging compatibility.

Quick Start

Demonstrate how to implement a simple error path using oops in a three-layer architecture (handler, service, repository) with context propagation.

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 across multiple architectural layers?โ–ผ

You can add structured context to Go errors by using a fluent builder pattern to attach key-value metadata, stack traces, and codes as errors propagate through HTTP handlers, services, and repositories. This ensures consistent context propagation and improved diagnosability.

What is the best way to separate public error messages from technical details in Go?โ–ผ

Separating public error messages from technical details in Go is achieved by attaching a user-facing public message alongside internal context and stack traces to the error. This allows safe external exposure while preserving internal observability for debugging.

How do I recover from panics and capture them as structured errors in Go?โ–ผ

Recovering from panics and capturing them as structured errors in Go involves using a dedicated recovery method during error wrapping. This converts recoverable panics into structured errors with attached stack traces and context, preventing application crashes while maintaining error visibility.

Can I propagate Go context into error handling builders?โ–ผ

Yes, you can propagate Go context into error handling builders by extracting or injecting context values directly into the error builder. This links the error instance to request-scoped data, ensuring errors carry relevant contextual metadata across service boundaries.

How does structured error handling improve observability in multi-layer Go applications?โ–ผ

Structured error handling improves observability in multi-layer Go applications by attaching machine-readable codes, stack traces, and contextual metadata to errors. This produces structured error outputs compatible with structured logging, simplifying root cause analysis and tracing.

When do I need machine-readable error codes in Go error handling?โ–ผ

You need machine-readable error codes in Go error handling when building production-grade systems that require programmatic error differentiation. Attaching explicit codes to errors allows upstream HTTP handlers to trigger specific retry logic or return precise API responses.