Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

implement whilelist for switch #54

@kolyshkin

Description

@kolyshkin

The following legitimate comparison using switch statement

func SwitchOnUnixErrors() {
       err := unix.Rmdir("somepath")
       switch err {
       case unix.ENOENT:
               return
       case unix.EPERM:
               return
       }
       fmt.Println(err)
}

results in a warning:

switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors

Apparently, whitelist of allowed direct comparisons, as implemented in allowed.go, is not used when analysing switch statements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions