Just like variables, constants also have specific storage locations but their value remains fixed. We use 'const' keyword to create a constant.
Constants are useful for the common values you would like to reuse over and over again but don't want to declare them every time you want to use them.
For instance,
func main(){
const x string = "Hello World!"
fmt.Println(x)
}
This code will also give us the same output 'Hello World!' on the screen.
Previous Posts In The Series
Introduction To 'Go' Programming Language(Learn 'Go' - Part 1)
25 Basic Keywords Of The Go Programming Language (Learn 'Go' - Part 2)
How To Set The Go Programming Environment On Your System?(Learn 'Go' - Part 3)
Create Your First Program In Go Language (Learn 'Go' - Part 4)
Strings In 'Go'(Learn 'Go' - Part 5)
Booleans In 'Go'(Learn 'Go' - Part 6)
Numbers In 'Go'(Learn 'Go' - Part 7)
Variables In 'Go'(Learn 'Go' - Part 8)
Upcoming Posts
Multiple Variables In 'Go'(Learn 'Go' - Part 10)