This is a creation in Article, where the information may have evolved or changed.
Definition of constants
- The value of the constant is determined at compile time
- Constants are defined in the same format as variables
- The right side of the equal sign must be a constant or constant expression
- A function in a constant expression must be a built-in function
1234567891011121314 |
Const int 1 Const ' A ' Const "123" Len ) Const 1,"2","3"const"234",len) |
Initialization rules and enumerations for constants
- When you define a constant group, if you do not provide an initial value, the expression that will use the upstream
- Using the same expression does not mean that you have the same value
- Iota is a constant counter, starting with 0, the group does not define 1 constants automatically incremented by 1
- The effect of enumerations can be achieved by initializing rules with iota
- Without encountering a const keyword, iota resets to 0
12345678910111213141516171819 |
Const "A" Iota //d = = 3) Const Iota //f = = 1) Const Iota Tuesdaywednesday ....) |
Operator
Operators in Go are combined from left to right, with precedence (high to low)
^ !
*/% << >> & &^
+ - | ^
= = = < <= >= >
<-
&&
||
1234567 |
6 : 0110 11 : 1011 -------------& 0010 | 1111 ^ 1101 |