Variables
package main
import "fmt"
func main() {
var str = "This would be auto infered as string"
fmt.Println(str)
// multiple variable declaration at once
var one, two int = 1, 2
fmt.Println(one, two)
// Again type will be inferred here on first initialization
var isHappy = true
fmt.Println(isHappy)
// variable is declared but not initialized
var willHold int
fmt.Println(willHold)
// shorthand for declaration as well as initialization
fruit := "oranges"
fmt.Println(fruit)
}Last updated