This is a creation in Article, where the information may have evolved or changed.
Constant is the amount of time that the program will not change when it runs
The constants in go are declared in the same way as variables, with combination declarations, parallel declarations, general declarations
/** * 定义常量 */const ( PI 3.14//这里并没有声明变量类型,编译器会自行判断 "yyyy-mm-DD HH-mm-ss" FORMAT //不提供数据类型和初始化值得常量视作和上一个常量相同(赋值表达式) 即FORMAT = "yyyy-mm-DD HH-mm-ss" 10//给变量指定明确的类型)
The value of a constant can also be the return value of a function that can determine the return value for the compilation period, such as Len, cap, and unsafe. Sizeof
count{ astring"abc" len(a) c = unsafe.Sizeof(b)}
Meiju
Keyword Iota defines a 0-based self-increment enumeration value in a constant group
//enumeration Const (_ = iota KB int64 = 1 << * Iota ) //iota = 1, (1 <<) = = (1 * 1024x768) MB //assignment expression omitted, ibid. GB TB) const (A, B = iota , iota << //0, 0 << C, D //1, 1 << )