-
:=
vs.=
They are both assignments in Go.
// = var name type = expression var x int = 1 // := short variable declaration name := expression // the type of name is determined by the type of expression
:=
is a declaration, whereas=
is an assignment. -
The
var
statement declares a list of variables; as in function argument lists, the type is last.A
var
statement can be at package or function level. -
nil
-
defer
-
References
理解:=||nil||defer in Go
最新推荐文章于 2023-10-16 13:53:56 发布