Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/muratmirgun/gophersnpx agentmods add skills/muratmirgun/gophers/go-error-handlingWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/muratmirgun/gophers/go-error-handling)<a href="https://agentmods.dev/skills/muratmirgun/gophers/go-error-handling"><img src="https://agentmods.dev/badge/skills/muratmirgun/gophers/go-error-handling.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00080 | $0.01879 |
| Opus 5 | $0.00040 | $0.00940 |
| Sonnet 5 | $0.00016 | $0.00376 |
| Haiku 4.5 | $0.00008 | $0.00188 |
Grade A, and why
go-error-handling scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 201 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Go Error Handling
Errors in Go are values. Treat them as part of the API: choose a strategy per failure mode, propagate with wrapping, inspect with errors.Is/As, and handle each error exactly once.
Core Rules
- Errors are values, not exceptions. Return them; do not panic across API boundaries.
- Handle each error exactly once. Either log it or return it — never both.
- The caller decides what is exceptional. Library code returns; binaries (or top-level handlers) decide whether to log, retry, or exit.
- Wrap only when you add real context. A wrap that just repeats the function name is noise. Use
%wto preserve identity;%vto deliberately hide an unstable type.
Strategy Decision
Pick the simplest strategy that meets the caller's needs:
| Strategy | When to use | Example |
|---|---|---|
| Opaque error (default) | Caller only needs to know something failed | errors.New("invalid input") |
| Sentinel error | Caller needs to test for a specific named condition | io.EOF, sql.ErrNoRows |
| Typed error | Caller needs structured fields (path, code, retry-after) | *os.PathError, *url.Error |
| Joined errors | A single operation produced several independent failures | errors.Join(errA, errB) |
Read references/strategy-decision.md when the caller's needs are unclear or when migrating between strategies without breaking callers.
Writing Errors
Strings
- Lowercase, no trailing punctuation. Errors are composed:
fmt.Errorf("write %s: %w", path, err)reads as one sentence. - Be specific.
"open config: permission denied"beats"failed to open file". - Do not include the function name. Stack context is added by wrapping at each layer.
Creating
// Opaque — the caller only checks != nil
return errors.New("invalid character in token")
// Sentinel — exported, package-level, named ErrXxx
var ErrNotFound = errors.New("user: not found")
// Typed — when callers need structured fields
type ValidationError struct {
Field string
Rule string
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("validation: %s violates %s", e.Field, e.Rule)
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 201 lines · 80 tokens per session scan A 55adbae8b59d
go-error-handling is a skill published in the GitHub repository muratmirgun/gophers (8 stars, last pushed 27d ago), licensed MIT. It adds 80 tokens to every session and 1,879 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
go
Use when writing Go services, CLIs, or libraries. Covers idiomatic error wrapping, goroutine and context discipline, interface design, table-driven tests, and the race detector.
golang-pro
Implements concurrent Go patterns using goroutines and channels, designs and builds microservices with gRPC or REST, optimizes Go application performance with pprof, and enforces idiomatic Go with generics, interfaces, and robust error handling. Use when building Go applications requiring concurrent programming…
developing-genkit-go
Develop AI-powered applications using Genkit in Go. Use when the user asks to build AI features, agents, flows, or tools in Go using Genkit, or when working with Genkit Go code involving generation, prompts, streaming, tool calling, or model providers.
programming
Applies strict, modern language practice (typed errors, exhaustive match, TDD) for Python, Rust, TypeScript, and Go. Use for work on .py, .rs, .ts, or .go files.
authoring-go-sdk-tasks
Writes Airflow task logic in Go using the Airflow Go SDK. Use when the user wants to implement Airflow tasks in Go, asks about BundleProvider/RegisterDags, the bundlev1 Registry/Dag interfaces, registering Go tasks (AddTask/AddTaskWithName), dependency injection by parameter type (context.Context, sdk.TIRunContext…
deploying-go-sdk-bundles
Builds, packs, and deploys compiled Airflow Go SDK bundles so the ExecutableCoordinator can run them. Use when the user wants to compile a Go task bundle, asks about go build, go tool airflow-go-pack, the AFBNDL01 self-contained executable bundle, packing or inspecting a bundle, placing it under executablesroot…