# Go Errors

> Go error handling patterns. Routes to specific patterns.

- Skill: `majiayu000/go-errors` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add majiayu000/go-errors`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/go-errors/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/go-errors

---


# Go Error Handling

## Route by Need
- Wrapping errors with context → see [wrapping/](wrapping/)
- Defining sentinel errors → see [sentinel/](sentinel/)
- Checking error types → see [checking/](checking/)

## Quick Check
- [ ] Never ignore errors (_ = fn())
- [ ] Wrap with context at boundaries
- [ ] Use errors.Is/As, not ==

## Common Pattern
```go
func ProcessFile(path string) error {
    f, err := os.Open(path)
    if err != nil {
        return fmt.Errorf("open %s: %w", path, err)
    }
    defer f.Close()

    if err := parse(f); err != nil {
        return fmt.Errorf("parse %s: %w", path, err)
    }
    return nil
}
```

## Resources
- [wrapping/](wrapping/) - Add context with fmt.Errorf %w
- [sentinel/](sentinel/) - Define package-level errors
- [checking/](checking/) - Type-safe error inspection

