Go

Go

Made by DeepSource

switch with single case can be rewritten as if or if-else CRT-A0014

Anti-pattern
Minor

switch statements with a single case can be rewritten as if-else or if.

Single case switch can be replaced by if-else as it appears to be more readable. This does not apply to type switch.

Bad practice

switch ok {
    case true:
        // body
}

Recommended

if ok {
    // body
}