Omit redundant control flow in your Go code.
Following cases should be considered to omit redundant control flow:
switch
statement in Go does not have automatic fallthrough, unlike languages like C. It is unnecessary to have a break statement as the final statement in a case block.func foo() {
fmt.Println("foo")
return
}
switch 1 {
case 1:
fmt.Println(“case one“)
break
case 2:
fmt.Println(“case two“)
}
func foo() {
fmt.Println("foo")
}
switch 1 {
case 1:
fmt.Println(“case one“)
case 2:
fmt.Println(“case two“)
}