// 1. センチネルエラーに Err プレフィックスがない var NotFoundError = errors.New("not found") // the sentinel error name `NotFoundError` should conform to the `ErrXxx` format var InvalidInput = errors.New("invalid input") // the sentinel error name `InvalidInput` should conform to the `ErrXxx` format var TimeoutErr = errors.New("timeout") // the sentinel error name `TimeoutErr` should conform to the `ErrXxx` format
// 2. エラー型に Error サフィックスがない type ValidationErr struct { Field string Message string } func(e *ValidationErr) Error() string { return e.Message } // the error type name `ValidationErr` should conform to the `XxxError` format
修正例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// 1. Err プレフィックスを付ける var ErrNotFound = errors.New("not found") var ErrInvalidInput = errors.New("invalid input") var ErrTimeout = errors.New("timeout")