Syntax
Reserved Words
break | default | func | interface | select |
---|---|---|---|---|
case | defer | Go | map | struct |
chan | else | Goto | package | switch |
const | fallthrough | if | range | type |
continue | for | import | return | var |
defer
In Go language, defer statements delay the execution of the function or method or an anonymous method until the nearby functions returns. Or in other words, defer function or method call arguments evaluate instantly, but they execute until the nearby functions returns. You can create a deferred method, or function, or anonymous function by using the defer keyword.
https://www.geeksforgeeks.org/defer-keyword-in-golang
Decision making
-
if statement - An if statement consists of a boolean expression followed by one or more statements.
-
if...else statement - An if statement can be followed by an optionalelse statement, which executes when the boolean expression is false.
-
nested if statement - You can use one if or else if statement inside another if or else if statement(s).
-
switch statement - A switch statement allows a variable to be tested for equality against a list of values.
-
Expression Switch − In expression switch, a case contains expressions, which is compared against the value of the switch expression.
-
Type Switch − In type switch, a case contain type which is compared against the type of a specially annotated switch expression.
-
-
select statement - A select statement is similar to switch statement with difference that case statements refers to channel communications.