Claude Code Go Skill for Wrapping Errors with Context
Attach operation context to a Go error while preserving the cause that upstream code needs to recognize.
中文Install in Claude Code
Use a Go module with local fixtures and the standard `fmt`, `errors` and `os` packages.
- Get the complete `docs/zh-TW/skills/golang-patterns` directory from the pinned GitHub checkout.
- Copy it under the target project's `.claude/skills/`. Confirm `.claude/skills/golang-patterns/SKILL.md`, open Claude Code at the project root, and call `/golang-patterns`.
Example task
Wrap errors in a config file reader. For a missing file, verify that `errors.Is(err, os.ErrNotExist)` still matches after the wrapper adds the operation context.What to check
The error has a useful operation description and retains the missing-file identity. The test checks both properties.
Original SKILL.md on GitHub · Updated
Frequently asked question
When does `errors.As` fit better?
Use `errors.As` when the caller needs a particular error type or fields on an error in the chain.