This is a creation in Article, where the information may have evolved or changed.
1. Looping statements
Go is only for a loop statement keyword, but supports 3 forms of initialization and stepping expressions can be multiple value conditional statements Each loop is re-examined, so it is not recommended to use a function in a conditional statement, try to calculate the condition in advance and replace the opening brace with a variable or constant with the conditional statement on the same line
1.1 For Infinite loops
1 for {2 // Break ; 3 // equivalent while 4 }
1.2 for with conditional expressions
1 if 3 {2// operation a3 }
1.3 for Classic style
1 for 0 3; i++{2//code3 }
1.2 Switch Selection
You can use any type or expression as a conditional statement without writing a break, and once the condition conforms to auto-terminate, if you want to continue with the next case, you need to use the Fallthrough statement to support an initialization expression (which can be parallel), and the right side must be the same line as the semicolon opening brace and the conditional statement.