slice, map即使为nil打印格式和空元素的情况一样, chan,func,interface,pointer为nil时,打印<nil>
当chan,func,pointer赋值后,都打印地址, interface赋值后,永远打印其dynamic value的格式
package main import "fmt" type I interface { m() } type T []byte func (t T) m() {} type Integer int func (integer Integer) m() {} type S struct { Name string } func (s S) m() {} func main() { var ( i I t T integer Integer s S ss *S ) fmt.Println(i, t, integer, s) i = t fmt.Println(i) i = integer fmt.Println(i) i = s fmt.Println(i) i = ss fmt.Println(i) i = T{45, 90} fmt.Println(i) i = Integer(88) fmt.Println(i) i = S{ Name: "tyui", } fmt.Println(i) i = &S{ Name: "vbnm", } fmt.Println(i) }
标签:Println,default,fmt,print,func,integer,Go,Integer,type From: https://www.cnblogs.com/dissipate/p/17330228.html