Declare immutable values in Go using the const keyword with a name and a compile-time value.
Use the const keyword followed by the name and value to declare a constant that cannot be changed at runtime.
const MaxRetries = 3
const Pi = 3.14159
const (
True = true
False = false
)
Constants are evaluated at compile time, must be of a basic type (like int, string, or bool), and are scoped to the package where they are defined.
A constant is a named value that you define once and never change while your program runs. Think of it like a label on a jar that says 'Sugar'βthe label itself never changes, even if you use the sugar in different recipes. You use them to make your code easier to read and to prevent accidental changes to important numbers or settings.