October 2015
Beginner to intermediate
400 pages
14h 44m
English
A var
declaration creates a variable of a particular type, attaches a name to
it, and sets its initial value. Each declaration has the general form
var name type = expression
Either the type or the = expression part may be omitted, but
not both.
If the type is omitted, it is determined by the initializer
expression.
If the expression is omitted, the initial value is the zero value
for the type, which is 0 for numbers, false for booleans,
"" for strings, and nil for interfaces and reference
types (slice, pointer, map, channel, function).
The zero value of an aggregate type like an array or a struct has the
zero value of all of its elements or fields.
The zero-value mechanism ensures that a variable always holds a well-defined ...