Constants
Declaration: const name type = expression
Untyped Constants
Constants can be untyped which is useful for numbers.
The constant will be implicitly converted to the required type.
Examples from package math:
const (
E = 2.71828182845904523536028747135266249775724709369995957496696763
Pi = 3.14159265358979323846264338327950288419716939937510582097494459
MaxInt8 = 1<<7 - 1 // 127
MinInt32 = -1 << 31 // -2147483648
)
Enums
Go has no enumerations but they can be mimicked by using constants.
The value for the keyword iota
is incremented by one after each line.