Skip to content

Commit 7a95ae0

Browse files
committed
Add linter rule to guard against use of os.Is* error functions
1 parent 1980fdd commit 7a95ae0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
version: "2"
2-
32
run:
43
build-tags:
54
- seccomp
@@ -37,6 +36,12 @@ linters:
3736
# going to be tricked into overwriting host files.
3837
- pattern: ^os\.Create$
3938
pkg: ^os$
39+
# os.Is* error checking functions predate errors.Is. Therefore, they
40+
# only support errors returned by the os package and subtly fail
41+
# to deal with other wrapped error types.
42+
# New code should use errors.Is(err, error-type) instead.
43+
- pattern: ^os\.Is(Exist|NotExist|Permission|Timeout)$
44+
pkg: ^os$
4045
analyze-types: true
4146
exclusions:
4247
rules:

0 commit comments

Comments
 (0)