When variable is declared with no explicit value assigned to it, Go assigns a default zero value for its type:

  • false for booleans
  • 0 for integers
  • 0.0 for floats
  • "" for strings
  • nil for pointers, functions, interfaces, slices, channels and maps
  • 0,0 for complex numbers (real and imaginary parts)

Examples:

// Equivalent
var i int
var i int = 0
 
// With this declaration
type T struct { i int; f float64; next *T }
t := new(T)
// or with this
var t T
// the following holds
t.i == 0
t.f == 0.0
t.next == nil

It makes a code clearer, removes a source of bugs that may be possible in C and C++ programs.