golang-samber-oops

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

2|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/adibfirman/dotfiles --skill golang-samber-oops-adibfirman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/adibfirman/dotfiles/tree/main/claude/.claude/skills/technical/golang/golang-samber-oops
Command: npx skills add https://github.com/adibfirman/dotfiles --skill golang-samber-oops-adibfirman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the problem of unstructured, low-context Go errors that lack reliable diagnostics like codes, stack traces, domain context, and user-safe messages.

Core Features & Use Cases

  • Structured error context: attach domain/feature, tags, correlation IDs, request/response data, and arbitrary attributes via a fluent builder.
  • Machine-readable error codes + public messages: differentiate technical details from user-facing messaging while keeping errors groupable in APM systems.
  • Better debugging and resilience: wrap underlying errors cleanly and convert panics into structured errors with panic recovery.
  • Use case: when a repository fails to query the database, wrap the error with query and user context, then propagate it through service and HTTP handler layers so on-call engineers can diagnose issues without re-asking for missing details.

Quick Start

Use the golang-samber-oops skill to help you refactor your Go code so every error is built with oops.In(), enriched with .With() attributes, and produced with .Wrapf() or .Errorf() using low-cardinality message strings.

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 domain context to Go errors?

You wrap Go errors using fluent builders like .With() and .Wrapf() to attach stack traces, domain context, and machine-readable codes, producing structured errors that propagate cleanly across repository, service, and HTTP handler layers.

How do I separate public error messages from technical details in Go services?

Separating public messages from technical Go error details is done using .Public() and GetPublic(), allowing you to expose user-safe messaging while retaining full diagnostic context for on-call engineers in APM systems.

What is the best way to recover from panics and log structured errors in Go?

Recovering from Go panics and logging structured errors is handled by converting panics into structured errors with panic recovery, then integrating with structured logging to capture stack traces and context attributes for reliable debugging.

How do I propagate context safely through Go error pipelines?

You propagate context safely through Go error pipelines using WithBuilder and FromContext to carry correlation IDs, request data, and arbitrary attributes across repository, service, and HTTP handler layers without losing domain context.

How do I group Go errors in APM systems using low-cardinality messages?

To group Go errors in APM systems, produce errors with .Wrapf() or .Errorf() using low-cardinality message strings, keeping errors groupable while attaching machine-readable codes, tags, and domain context for diagnostics.