npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
Define package-level errors as exported variables for expected error conditions.
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.
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: basic errors, wrapping with %w, sentinel errors, custom types, errors.Is, and Unwrap for robust apps.
Share bugs, ideas, or general feedback.
Define package-level errors as exported variables for expected error conditions.
package user
import "errors"
// Sentinel errors - define at package level
var (
ErrNotFound = errors.New("user not found")
ErrInvalidEmail = errors.New("invalid email format")
ErrDuplicate = errors.New("user already exists")
)
func Get(id int) (*User, error) {
u, ok := db[id]
if !ok {
return nil, ErrNotFound
}
return u, nil
}
// Bad: Creates new error each time (can't use errors.Is)
func Get(id int) (*User, error) {
if _, ok := db[id]; !ok {
return nil, errors.New("user not found")
}
return db[id], nil
}
// Bad: String comparison is fragile
if err.Error() == "user not found" { }
ErrErrNotFound, not ERR_NOT_FOUNDErrInvalidEmail, not ErrBadInputUse sentinel errors for:
Avoid for: