Web Development

Variables are used to store information to be referenced and used by programs. Here’s how to work with Go Language variables.

Go Language Code

package main

import "fmt"
func main() {

    var a string = "My Name is Teejay"
    fmt.Println(a)

    var b int = 123456
    fmt.Println(b)

    var c = true
    fmt.Println(c)

    /* below is a shorthand for 'var d string = Teejay' */
    d := "Teejay"
    fmt.Println(d)

    /* below is a shorthand for 'var e int = 500' */
    e := 500
    fmt.Println(e)
}

Output

$ go run variables.go 
My Name is Teejay
123456
true
Teejay
500