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