2
Golang 中 error(nil) 为啥 type 也是 unset?
source link: https://www.v2ex.com/t/809274
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
m := error(nil)
n := (*error)(nil)
fmt.Printf("%T %+v \n", m, m)
fmt.Printf("%T %+v \n", n, n)
得到的结果
<nil> <nil>
*error <nil>
为啥 m 的 type 是 unset 呢?
第 1 条附言 · 4 小时 49 分钟前
errorInterface := reflect.TypeOf((*error)(nil)).Elem()
为啥这里 TypeOf 参数用 error(nil)不行
为啥这里 TypeOf 参数用 error(nil)不行
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK