Switch better than if-else in Go?

I am sure you have wondered if switch is more efficient than if-else, or vice versa. So here is a little experiment to compare them.

  1. If-else
func If(i int) bool {
if i == 1 {
return true
} else {
return false
}
}

2. Switch with no condition

func Switch(i int) bool {
switch {
case i == 1:
return true
default:
return false
}
}

3. Switch with constants

func SwitchConst(i int) bool {
switch i {
case…