Go has a switch case much like other languages.

x := 3
switch x {
	case 1:
		// do something
	case 2, 3, 4:
		// do something else
	default:
		panic(fmt.Errorf("ahhhhh"))
}

Conditional switch case

Go also has a conditional switch case based on a statement init.

switch result := calculate(15); {
	result > 10:
		// do something
	result == 6:
		// do something else
	result < 10:
		fmt.Println("alkdfj")
}

Fallthrough keyword

The go fallthrough keyword tells the program to also run the next case block.

switch letter {
	case 'a', 'b', 'c':
		// do something
		fallthrough // <-- this causes the execution of the next case body
	case 'A', 'B', 'C':
		// this will be executed even if letter == 'a', 'b', 'c'
	default:
		// if none match
}