golang-samber-oops

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

1|Updated May 27, 2026
One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-oops-dmwin72015
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-oops-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the difficulty of diagnosing Go failures when errors lack structured context, consistent codes, low-cardinality messages, and stack traces that are useful for on-call debugging and APM grouping.

Core Features & Use Cases

  • Structured context as error attributes: attaches domain, tags, user/tenant context, and arbitrary key-value data using a fluent builder instead of stuffing variable data into message strings.
  • Error codes and public vs technical messages: sets machine-readable identifiers for routing/metrics and user-safe messages separate from developer-facing technical details.
  • Stack traces and panic recovery: captures call stacks and converts panics to structured errors at goroutine boundaries with .Recover()/.Recoverf().
  • Layered wrapping across boundaries: promotes adding relevant context at handler/service/repository boundaries using .Wrap()/.Wrapf() for end-to-end traceability.
  • APM-friendly low-cardinality output: keeps the message stable while variable identifiers flow through .With() attributes to preserve aggregation.

Quick Start

Use the golang-samber-oops skill to rewrite your existing Go error creation and wrapping so that variable identifiers (user ID, tenant ID, order ID) are added with With/User/Tenant attributes and the resulting error includes Code, Domain, and a public message where appropriate.

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 for APM aggregation?

Structured Go errors use a fluent builder to attach domain context, tags, and user identifiers as attributes. This keeps variables out of message strings, preserving low-cardinality output to maintain reliable APM aggregation and grouping.

What is the best way to capture stack traces and recover from panics in Go goroutines?

Stack traces and panic recovery in Go goroutines are handled by converting panics into structured errors at goroutine boundaries. Using dedicated recovery functions captures call stacks while attaching domain context and error codes to the failure.

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

Public user-safe messages and technical developer details in Go are separated by setting a machine-readable error code alongside a distinct public message. This routes failures correctly while ensuring end users only see safe, sanitized text.

Can I wrap Go errors across HTTP handler, service, and repository boundaries?

Go errors can be wrapped across HTTP handler, service, and repository boundaries using layered wrapping functions. This adds relevant context at each boundary, preserving end-to-end traceability from the initial failure point to the external response.

Why do my Go error logs have high cardinality and break APM grouping?

Go error logs break APM grouping when variable identifiers like user or tenant IDs are stuffed directly into message strings. Moving this variable data into structured attributes keeps the error message stable to preserve aggregation.

When do I need structured error handling instead of standard Go errors?

Structured error handling is needed when failures require consistent codes, stack traces, and domain context for on-call debugging. It replaces standard Go errors when you must preserve traceability across boundaries and ensure APM-friendly logging.