Like for, the if statement can start with a short statement to execute
before the condition.
Variables declared by the statement are only in scope until the end of
the if.
Variables declared inside an if short statement are also available
inside any of the else blocks.
Switch
Go’s switch is like the one in C, C++, Java, JavaScript, and PHP, except
that Go only runs the selected case, not all the cases that follow. In
effect, the break statement that is needed at the end of each case in
those languages is provided automatically in Go. Another important
difference is that Go’s switch cases need not be constants, and the
values involved need not be integers.
Switch without a condition is the same as switch true. This construct
can be a clean way to write long if-then-else chains.
Type switches are also a thing:
Defer
A defer statement defers the execution of a function until the
surrounding function returns. The deferred call’s arguments are
evaluated immediately, but the function call is not executed until the
surrounding function returns.
Deferred function calls are pushed onto a stack. When a function
returns, its deferred calls are executed in last-in-first-out order.