cloudaice / learnGo

there are something about Go Useage
MIT License
0 stars 0 forks source link

不要轻易对interface类型做nil判断 #16

Open cloudaice opened 8 years ago

cloudaice commented 8 years ago

Go语言中的interface类型由两个部分组成:类型和值。只有类型和值都为nil的时候,这个时候使用v == nil才会为真。往往很多时候变量的值为nil,但是类型并不是nil,这个时候,其实是没有办法通过v == nil来做判断的。