Switch statements express conditionals across many branches.
Here’s a basic
You can use commas to separate multiple expressions
in the same
case statement. We use the optional
default case in this example as well.
switch without an expression is an alternate way
to express if/else logic. Here we also show how the
case expressions can be non-constants.
The switch in Go+ defaults to a break at the end of each case. Use fallthrough to enforce the code for the subsequent cases.
Next example: For