golang-samber-oops

Build structured Go errors with samber/oops fluent builder chains.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

samber/oops converts unstructured Go errors into structured, diagnosable error objects that carry domain context, stack traces, machine-readable codes, user-safe public messages, and rich attributes for observability.

Core Features & Use Cases

  • Structured error context: Attach key-value attributes via With/Tags/In and use WithContext to extract values from Go context.
  • Fluent error builder chain: Build errors with a composable pattern and wrap existing errors to preserve original causes.
  • Operational observability: Ensure low-cardinality messages for clean grouping in APM/logging systems, while variable data is stored as attributes.
  • Layered error handling: Add context at package boundaries (HTTP handler → service → repository) using Wrap/Wrapf and appropriate domain/tag information.
  • Panic recovery in goroutines: Convert panics into structured errors using oops.Recover or builder .Recover at goroutine boundaries.
  • Public vs technical messages: Provide a user-safe public message using .Public and keep technical details in Errorf/Wrapf.
  • Logger integration: Extract fields (Code, Domain, Tags, Context, Stacktrace) and log the structured error object.
  • References for advanced patterns: Assertions configuration and recommended practices are documented in references/advanced.md.

Quick Start

Use the golang-samber-oops skill to rewrite error handling so each error is built with a fluent builder, includes .In domain + .Code error slug + structured attributes via .With/.User/.Tenant, uses .Public for user-safe messaging, and converts goroutine panics with .Recover.

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 observability?

Structured Go errors attach key-value attributes like domain, code, and tenant to error objects. This preserves diagnostic context across service boundaries, making incidents easier to debug and correlate in APM systems.

What's the best way to wrap errors across Go repository and service layers?

Wrapping errors across Go layers uses a fluent builder chain to add domain context at package boundaries. You wrap existing errors with Wrap or Wrapf, preserving the original cause while appending structured tags and domain information.

How do I recover goroutine panics as structured errors in Go?

Goroutine panics convert to structured errors using oops.Recover or builder .Recover at goroutine boundaries. This captures panic context as structured attributes, preventing unstructured crashes from losing diagnostic data.

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

User-safe messages are separated by using .Public for user-facing text, while technical details remain in low-cardinality Errorf or Wrapf messages. Variable data is stored as structured attributes, keeping logs clean.

Why should Go error messages use low cardinality for logging?

Low-cardinality Go error messages ensure clean grouping in APM and logging systems. Variable data is stored as structured attributes rather than interpolated into the message string, preventing log explosion and improving aggregation.

Can I extract values from Go context into structured error attributes?

Yes, you extract values from Go context into structured errors using WithContext. This pulls relevant contextual data directly from the Go context object, attaching it as attributes to the structured error builder chain.