From 58d24d2dfb258906ffefaecff3adc0ee2d82652d Mon Sep 17 00:00:00 2001 From: Curd Becker Date: Tue, 9 Dec 2025 03:29:44 +0100 Subject: [PATCH] Add linter rule to guard against use of os.Is* error functions Signed-off-by: Curd Becker --- .golangci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 684f98960..c5ed654c7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,6 +37,12 @@ linters: # going to be tricked into overwriting host files. - pattern: ^os\.Create$ pkg: ^os$ + # os.Is* error checking functions predate errors.Is. Therefore, they + # only support errors returned by the os package and subtly fail + # to deal with other wrapped error types. + # New code should use errors.Is(err, error-type) instead. + - pattern: ^os\.Is(Exist|NotExist|Permission|Timeout)$ + pkg: ^os$ analyze-types: true exclusions: rules: