$ show pkg/errors
This is a Go library providing error handling primitives with stack trace capture, wrapping, and cause retrieval. The primary functions are `New`, `Errorf`, `Wrap`, `Wrapf`, `WithStack`, `WithMessage`, and `Cause`. It implements the `fmt.Formatter` interface for detailed error formatting and includes compatibility with Go 1.13's `errors.Is`, `As`, and `Unwrap`. The library is self-contained with no external dependencies beyond the standard library. It is in maintenance mode as the Go standard library has adopted similar functionality, but it remains widely used for its stack trace capabilities. The architecture is a single package with a few types: `fundamental`, `withStack`, `withMessage`, and `Frame`/`StackTrace` for stack representation. The code is well-tested, well-documented, and demonstrates idiomatic Go patterns.
The LLM identified 2 files worth highlighting for reuse:
Provides the `Frame` type (a program counter) and `StackTrace` (slice of `Frame`) with formatting methods (`%s`, `%d`, `%n`, `%v`, `%+v`), plus `MarshalText` for JSON output. The `callers()` function captures the current stack. This component is self-contained, has no internal imports beyond standard library, and can be extracted as a standalone stack trace utility for any Go project.
Implements the core error types: `fundamental` (message + stack), `withStack` (wraps an error with a stack trace), `withMessage` (wraps an error with a message). Includes `Cause` for retrieving the original error, and `Wrap`/`Wrapf`/`WithStack`/`WithMessage` functions. The formatting logic for `%+v` prints detailed stack traces. This component is the foundation of the library and demonstrates a clean, composable error construction pattern.