Constants
Go supports constants, which behave like variables but cannot change their values. Constants in Go are defined with the help of the const
keyword. Constants can be either global or local. However, if you are defining too many constant values with a local scope, you might need to rethink your approach.
The main benefit you get from using constants in your programs is the guarantee that their value will not change during program execution. Strictly speaking, the value of a constant variable is defined at compile time, not at runtime—this means that it is included in the binary executable. Behind the scenes, Go uses Boolean, string, or numeric as the type for storing constant values because this gives Go more flexibility when dealing with constants.
Some possible uses of constants include defining configuration values such as the maximum number of connections or the TCP/IP port number used and defining physical constants such as the speed of light or the gravity...