=- appointment. more about assignment in Go: Assignments
the subtle difference between =and :=is when =used in variable declarations.
The general form for declaring a variable in Go is:
var name type = expression
, . type, = expression , .
:
var x int = 1
var a int
var b, c, d = 3.14, "stackoverflow", true
:= short variable declaration,
name := expression
: := , =
, . , , , :=
:
r := foo() // ok, declare a new variable r
r, m := bar() // ok, declare a new variable m and assign r a new value
r, m := bar2() //compile error: no new variables
, := . , "if", "for" "switch", .
: