Short Variable Declarations in Golang

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

package main

import (
	"fmt"
)

func main() {

	a := 123
	fmt.Println("a:", a)

	id, fullName, age, status, price, key := "p01", "name 1", 20, true, 4.5, 'D'
	fmt.Println("id:", id)
	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

a: 123
id: p01
age: 20
full name: name 1
status: true
price: 4.5
key: D and position in ASCII: 68