This is a created article in which the information may have evolved or changed. Recently, when I wrote the Go Language program, I found a problem. Look at the code first:
Musicplay Project Main.gopackage mainimport ("FMT") type Cat interface {Meow ()}type tabby struct{}func (*tabby) Meow () { Fmt. Println ("Meow")}func Getacat () Cat {var mytabby *tabby = nil//Oops, we forgot to set Mytabby to a real valuereturn mytab By}func Testgetacat () {var ICat catvar tabby *tabby = Nilicat = Tabby//icat = Getacat ()//icat = Nilif ICat = nil {fmt. Println ("Gettest failed!")}} Func Main () {Testgetacat ()}
In calling the Testgetacat () function, my idea is that icat should be nil and then call FMT. Println ("Gettest failed!"). Run the result is no call, this suddenly I feel a bit confused, and then directly add ICAT = nil but is can, so Baidu a bit. Found the article again, address: http://geek.csdn.net/news/detail/102187.
His understanding is this: icat points to a tabby pointer object that points to nil. So ICat is not nil.
Only to be able to understand it for the time being.