Zero Values
Last updated
Last updated
Variables declared without an explicit initial value are given their zero value.
Type | Zero Value |
---|---|
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.
Integer
0
Floating point
0.0
Boolean
false
String
“”
Pointer
nil
Interface
nil
Slice
nil
Map
nil
Channel
nil
Function
nil