-
:=
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
猜你喜欢
转载自blog.csdn.net/The_Time_Runner/article/details/108893370
今日推荐
周排行