Constants- Go Language

Last Updated : 11 Apr, 2023

As the name CONSTANTS suggests, it means fixed. In programming languages also it is same i.e., once the value of constant is defined, it cannot be modified further. There can be any basic data type of constants like an integer constant, a floating constant, a character constant, or a string literal. 

How to declare: Constants are declared like variables but in using a const keyword as a prefix to declare a constant with a specific type. It cannot be declared using ":=" syntax. 

Example: 

Go
package main

import "fmt"

const PI = 3.14

func main() 
{
    const GFG = "GeeksforGeeks"
    fmt.Println("Hello", GFG)

    fmt.Println("Happy", PI, "Day")