golang-samber-oops

Attach context, stack traces, and public messages to Go errors with samber/oops.

5|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/omarluq/og-template --skill golang-samber-oops-omarluq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/omarluq/og-template/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/omarluq/og-template --skill golang-samber-oops-omarluq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go applications often struggle with errors that lack context, making debugging hard. samber/oops provides a fluent builder to attach domain, codes, user-facing messages, and structured attributes, while preserving stack traces.

Core Features & Use Cases

  • Structured context: attach attributes via In, With, User, Tenant, and more, so errors carry rich metadata.
  • Stack traces and machine-readable codes: enable precise error grouping and diagnostics.
  • Public vs technical messages: separate user-safe messages from internal details, with GetPublic support.
  • Panic recovery and logging integration: recover panics into structured errors and integrate with common loggers.
  • Cross-layer usage: propagate contextual information across HTTP handlers, services, and repositories.

Quick Start

Compose a minimal error using the oops builder to attach domain, code, and a public message for the user.

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

You propagate context across HTTP handlers, services, and repositories by wrapping errors with consistent builder methods like Wrap and Wrapf. This maintains domain metadata, codes, and stack traces consistently across all application layers.

How do I separate user-safe messages from internal error details in Go?

Yes, you can recover panics into structured errors by integrating panic recovery with the error builder. This captures runtime panics and converts them into structured errors with context, stack traces, and codes for consistent logging and diagnostics.

What is the best way to group and diagnose Go application errors?

Structured error handling differs from standard Go errors by using a fluent builder to attach domain, codes, user-facing messages, and structured attributes. It preserves stack traces and separates public messages from technical details, which standard errors lack natively.

How do I propagate structured errors across HTTP handlers and service layers in Go?

You propagate context across HTTP handlers, services, and repositories by wrapping errors with consistent builder methods like Wrap and Wrapf. This maintains domain metadata, codes, and stack traces consistently across all application layers.

Can I recover panics and convert them into structured errors in Go?

Yes, you can recover panics into structured errors by integrating panic recovery with the error builder. This captures runtime panics and converts them into structured errors with context, stack traces, and codes for consistent logging and diagnostics.