Declare Variables in Golang

Create new folder named src. In src folder, create new file named main.go as below:

package main

import (
	"fmt"
)

func main() {

	var age int
	var fullName string
	var status bool
	var price float64
	var key rune

	age = 20
	fullName = "ABC"
	status = true
	price = 4.5
	key = 'A'

	fmt.Println("age:", age)
	fmt.Println("full name:", fullName)
	fmt.Println("status:", status)
	fmt.Println("price:", price)
	fmt.Printf("key: %c and position in ASCII: %d", key, key)

}




Open Terminal windows in Visual Studio Code and run command line: go run main.go

age: 20
full name: ABC
status: true
price: 4.5
key: A and position in ASCII: 65