golang-samber-oops

Generate structured samber/oops errors with codes, attributes, and stack traces.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Go engineers replace vague, context-poor error handling with structured, code-based errors that include stack traces and rich attributes, so on-call debugging and monitoring become faster and more reliable.

Core Features & Use Cases

  • Structured context on errors: Attach key-value attributes using builder methods like With(), WithContext(), User(), Tenant(), and Trace/Span for consistent diagnostics across layers.
  • Error codes and public messages: Provide machine-readable identifiers via Code() and user-safe responses via Public(), keeping technical details separate from what clients see.
  • Fluent builder pattern for consistency: Standardize error creation with In(), Tags(), Errorf(), Wrap()/Wrapf(), Join(), and Recover() to ensure uniform patterns across services.
  • Panic-to-error recovery: Use Recover() at goroutine boundaries to convert panics into structured errors with context and stack traces.
  • Context propagation through middleware: Persist an error builder in request context with WithBuilder() and retrieve it downstream with FromContext().
  • APM-friendly low-cardinality messages: Keep Errorf/Wrapf messages stable while moving variable data into attributes so telemetry groups correctly.

Quick Start

Apply samber/oops in your Go code by creating errors with the fluent builder (set domain with In(), attach variable fields with With/WithContext/User/Tenant, set Code() and optionally Public()), wrapping underlying errors with Wrapf(), and using Recover() to convert panics into structured, stack-traced errors.

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

You can add structured context to Go errors by using a fluent builder pattern to attach key-value attributes, error codes, and stack traces, replacing vague error handling with rich diagnostics for faster debugging.

What is the best way to keep variable data out of Go error messages for APM?

To keep APM telemetry groups correct, maintain low-cardinality error messages by placing variable data into error attributes using builder methods, rather than interpolating dynamic values directly into the error message string.

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

You can recover from goroutine panics by calling a Recover() method at goroutine boundaries, which converts the panic into a structured error that retains context and stack traces for observability.

Can I propagate an error builder through HTTP middleware context in Go services?

Yes, you can propagate an error builder through HTTP middleware by persisting it in the request context and retrieving it downstream, ensuring consistent diagnostic attributes across layered service boundaries.

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

You can separate user-safe messages from technical details by setting machine-readable identifiers via an error code method and user-safe responses via a public message method, keeping client-facing information clean.

Does structured error handling work for layered Go services like repositories and HTTP handlers?

Yes, structured error handling applies to layered Go services by standardizing error creation across HTTP handlers, service layers, and repositories using a fluent builder to ensure uniform diagnostic patterns.