In Golang when a variable is declared it is initialized with zero value as described in the specification.
http://golang.org/ref/spec#The_zero_value
But is it good coding practice to make use of this property and do not explicitly initialize your variable if it needs to initialized with the default value.
for example in the following example
http://play.golang.org/p/Mvh_zwFkOu
package main
import "fmt"
type B struct {
isInit bool
Greeting string
}
func (b *B) Init() {
b.isInit = true
b.Greeting = "Thak you for your time"
}
func (b *B) IsInitialized() bool {
return b.isInit
}
func main() {
var b B
if !b.IsInitialized(){
b.Init()
}
fmt.Println(b.Greeting)
}
the program relies on the default value of boolean to be false.