Skip to content

Commit 58d24d2

Browse files
committed
Add linter rule to guard against use of os.Is* error functions
Signed-off-by: Curd Becker <me@curd-becker.de>
1 parent 536e183 commit 58d24d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ linters:
3737
# going to be tricked into overwriting host files.
3838
- pattern: ^os\.Create$
3939
pkg: ^os$
40+
# os.Is* error checking functions predate errors.Is. Therefore, they
41+
# only support errors returned by the os package and subtly fail
42+
# to deal with other wrapped error types.
43+
# New code should use errors.Is(err, error-type) instead.
44+
- pattern: ^os\.Is(Exist|NotExist|Permission|Timeout)$
45+
pkg: ^os$
4046
analyze-types: true
4147
exclusions:
4248
rules:

0 commit comments

Comments
 (0)