golang-samber-oops

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go developers often struggle with adding meaningful, consistent context to errors. This Skill demonstrates using samber/oops to attach domain, trace, and user-facing data to errors while preserving clear separation between technical details and public messages.

Core Features & Use Cases

  • Fluent error builder for domain, codes, context, and public messages.
  • Context propagation with WithBuilder/FromContext across HTTP handlers, services, and repositories.
  • Panic recovery and stack traces for reliable error handling in goroutines.
  • Accessors for error metadata and easy logging integration.

Quick Start

Create a base error using the fluent builder pattern (In, Code, Public) and wrap underlying errors for all failure paths.

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 Golang errors across service layers?

To add structured context to Golang errors, use a fluent builder pattern to attach domain, trace, and user-facing data. This separates technical details from public messages while propagating context cleanly across HTTP handlers, services, and repositories.

What is the best way to wrap errors with stack traces and codes in Go?

The best way to wrap errors with stack traces and codes in Go is using a structured error builder. It allows you to fluently assign error codes, wrap underlying failures, and append stack traces for reliable debugging and consistent error reporting.

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

To recover from panics in goroutines and convert them to structured errors, apply panic recovery mechanisms within your error handling logic. This captures stack traces and transforms unexpected runtime panics into manageable, structured error outputs.

Can I propagate context and trace data through Go HTTP handlers using structured errors?

Yes, you can propagate context and trace data through Go HTTP handlers using structured errors. By extracting context from incoming requests and passing it through service layers, you ensure consistent trace data attaches to any generated errors.

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

To separate technical error details from public user-facing messages in Go, use an error builder that supports distinct fields for internal logs and external responses. This ensures sensitive stack traces remain internal while clients receive safe public messages.

Does structured error handling in Go support multi-format outputs for logging integration?

Yes, structured error handling in Go supports multi-format outputs for logging integration. Accessors for error metadata allow you to easily extract domain, codes, and context, enabling seamless formatting for various logging systems and user feedback.