Zero Values

Golang provides the mechanism to set default values for declared variables. How does it work? When we declare a variable without explicit initialization, Golang will allocate memory for such a variable by setting a zero value for it. var var1 bool var var2 int var var3 float64 var var4 string var var5 *int var var6 []int var var7 map[int]string Let’s see what values are set for the particular variables listed above:...

April 9, 2023 · 2 min · Agata Werszler