:= — declare and initialize. = — assign.
1// := — short variable declaration2x := 42 // Declares x and assigns 4234// = — assignment5x = 100 // Assigns new value to x67// var — explicit declaration8var y int = 10
Rules for :=:
1func main() {2 x := 13 x := 2 // Error! x already declared45 x, y := 1, 2 // OK — y is new6 x, y = 3, 4 // OK — assignment7}