If you have variable and it’s value would not change, you can use the const
keyword. There is no way to change their value later, which means they are unchangeable and read-only.
example you have simple PI value and it is a fix value. You dont want to change it later
package main import ("fmt") const PI = 3.14 func main() { fmt.Println(PI) }
*** important ***
DO NOT FORGET assign constant name in uppercase letters (this make easy identification and differentiation from variables)
const CONSTNAME type = value
example 1 :
const A int = 1 // sytax
example 2:
const A = 1 // also can be declared withour type, depend on goven value Go assinng a type
example 3:
const ( // also possible assign multiple constans
A int = 1
B = 3.14
C = “Hi!”
)