Go language conditional statements
Conditional statements require the developer to specify one or more conditions, and determine whether to execute the specified statement by testing whether the condition is true, and execute another statement when the condition is false.
The following figure shows the structure of conditional statements in programming languages:

The Go language provides the following conditional judgment statements:
| statement | Description |
|---|---|
| if statement | if statementConsists of a boolean expression followed by one or more statements. |
| if...else statement | if statementcan be followed by an optionalelse statement, the expression in the else statement is executed when the boolean expression is false. |
| nested if statement | You caniforelse ifembed one or more within the statementiforelse ifstatement. |
| switch statement | switchThe statement is used to execute different actions based on different conditions. |
| select statement | selectstatement is similar toswitchstatement, but select will randomly execute one runnable case. If no case is runnable, it will block until a case is runnable. |
other extensionsNote: Go does not have a ternary operator, so it does not support?:form of conditional judgment