Short variable declarations

Inside a function, := is the shorthand for declaring and initializing a variable — no var, no explicit type needed. You’ll use this all the time.

Outside a function, every statement must start with a keyword like var or func, so := isn’t available there.

package main

import "fmt"

func main() {
	var i, j int = 1, 2
	k := 3
	c, python, java := true, false, "no!"

	fmt.Println(i, j, k, c, python, java)
}