Go

Go

Made by DeepSource

Empty fallthrough in switch statement can be avoided CRT-A0003

Anti-pattern
Major
Autofix

Empty fallthrough can be avoided by clubbing together consecutive cases, using multi-case values.

Unlike languages like C, where a break statement is required at the end of a case to avoid fallthrough into next case, Go requires a fallthrough statement to pass control to the next case. When the fallthrough statement is the only statement used in a case, and a non-default case follows, the cases can be merged.

Bad practice

switch kind {
case reflect.Int:
    fallthrough
case reflect.Int32:
    return Int
}

Recommended

switch kind {
case reflect.Int, reflect.Int32:
    return Int
}