npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
Use `errors.Is` to check sentinel errors and `errors.As` to extract error types.
Guides Go error handling: sentinels vs custom types, fmt.Errorf wrapping (%w/%v), error flow, propagation across packages, errors.Is/As, with anti-pattern checker script.
Provides Go error handling patterns: wrapping with %w, sentinel errors, custom types, errors.Is/As. Use for implementing, designing error types, debugging chains, reviewing code.
Implements and reviews Go error handling: creates/wraps errors with fmt.Errorf, checks via errors.Is/As/Join, uses sentinels/custom types, logs with slog. Audits codebases and PRs.
Share bugs, ideas, or general feedback.
Use errors.Is to check sentinel errors and errors.As to extract error types.
// CORRECT
if errors.Is(err, user.ErrNotFound) {
return http.StatusNotFound
}
// WRONG - breaks with wrapped errors
if err == user.ErrNotFound { }
// CORRECT - extracts specific error type
var pathErr *fs.PathError
if errors.As(err, &pathErr) {
log.Printf("failed path: %s", pathErr.Path)
log.Printf("operation: %s", pathErr.Op)
}
// WRONG - only checks direct type
if pathErr, ok := err.(*fs.PathError); ok { }
func HandleError(err error) {
// Check sentinel errors
if errors.Is(err, user.ErrNotFound) {
fmt.Println("User not found")
return
}
// Extract custom error types
var validationErr *ValidationError
if errors.As(err, &validationErr) {
fmt.Printf("Validation failed: %v\n", validationErr.Fields)
return
}
// Extract standard library errors
var pathErr *fs.PathError
if errors.As(err, &pathErr) {
fmt.Printf("File operation failed: %s\n", pathErr.Path)
return
}
// Generic error
fmt.Printf("Unknown error: %v\n", err)
}
errors.Is: Checks if error matches a sentinel value (works through wrapping)errors.As: Extracts error of specific type (works through wrapping)== or type assertions for wrapped errors