Zero Values
Last updated
Was this helpful?
Last updated
Was this helpful?
Variables declared without an explicit initial value are given their zero value.
Integer
0
Floating point
0.0
Boolean
false
String
“”
Pointer
nil
Interface
nil
Slice
nil
Map
nil
Channel
nil
Function
nil
The elements of an array or struct will have its fields zeroed if no value is specified. This initialization is done recursively.
Hence, each element of such a variable or value (struct, in this case) is set to the zero value for its type.