Go Error Handling
Write clean, idiomatic error handling in Go using modern patterns and best practices.
Usage
Ask about error handling patterns or share code for recommendations on proper Go error management.
Examples
- "How do I wrap errors with context in Go?"
- "When should I use sentinel errors vs custom types?"
- "Show me the errors.Is and errors.As patterns"
Guidelines
- Always wrap errors with context using fmt.Errorf and %w
- Show proper use of errors.Is and errors.As for checking
- Recommend sentinel errors for expected conditions
- Cover custom error types with additional fields
- Explain when to return errors vs log and continue