Go if and switch
if
The if statement in Go is similar to most programming languages, except for a few quirks in Go: The expression does not require parentheses (), and the opening brace { cannot start on a new line.
if booleanExpression1 {
//...
} else if booleanExpression2 {
//...
} else {
//...
}
switch
The switch statement in Go is also similar to most programming languages, but it has a few quirks in Go: It does not require an explicit break statement, and it automatically terminates once a case matches.
switch variableName {
case condition1:
//...
case condition2,condition3,condition4: //test multiple values that might satisfy the condition simultaneously, separated by commas
//...
case condition5:
//...
default:
//...
}
Take a break
πππ γBTTH Year EP102γThe Four Pavilions Grand Meeting began, Xiao Yan rescued Lin Yan