← Back to list

go-sentinel-errors
by JamesPrial
WIP - collection of various Claude stuff i make/use/have_Claude_hallucinate
⭐ 2🍴 0📅 Jan 23, 2026
SKILL.md
name: go-sentinel-errors description: Define package-level sentinel errors using errors.New
Sentinel Errors
Pattern
Define package-level errors as exported variables for expected error conditions.
CORRECT
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
}
WRONG
// 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" { }
Naming Convention
- Prefix with
Err - Use camel case:
ErrNotFound, notERR_NOT_FOUND - Be specific:
ErrInvalidEmail, notErrBadInput
When to Use
Use sentinel errors for:
- Expected business logic errors
- Public API boundaries
- Conditions callers need to handle differently
Avoid for:
- Unexpected/rare conditions
- Internal implementation details
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon
