-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package issues | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// Regression test for: https://github.com/polyfloyd/go-errorlint/issues/11 | ||
|
||
var ErrInvalidConfig = errors.New("invalid configuration") | ||
|
||
// invalidConfig type is needed to make any error returned from Validator | ||
// to be ErrInvalidConfig. | ||
type invalidConfig struct { | ||
err error | ||
} | ||
|
||
func (e *invalidConfig) Is(target error) bool { | ||
return target == ErrInvalidConfig | ||
} | ||
|
||
type Errno uintptr | ||
|
||
func (e Errno) Is(target error) bool { | ||
switch target { | ||
case os.ErrPermission: | ||
return e == Errno(syscall.EACCES) || e == Errno(syscall.EPERM) | ||
case os.ErrExist: | ||
return e == Errno(syscall.EEXIST) || e == Errno(syscall.ENOTEMPTY) | ||
case os.ErrNotExist: | ||
return e == Errno(syscall.ENOENT) | ||
} | ||
return false | ||
} |