Agent skill

go-errors

Go error handling patterns. Routes to specific patterns.

Stars 3
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/JamesPrial/claudefiles/tree/main/skills/golang/errors

SKILL.md

Go Error Handling

Route by Need

  • Wrapping errors with context → see wrapping/
  • Defining sentinel errors → see sentinel/
  • Checking error types → see 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/ - Add context with fmt.Errorf %w
  • sentinel/ - Define package-level errors
  • checking/ - Type-safe error inspection

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results