fallthrough
in switch statement can be avoided CRT-A0003Empty 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.
switch kind {
case reflect.Int:
fallthrough
case reflect.Int32:
return Int
}
switch kind {
case reflect.Int, reflect.Int32:
return Int
}