浏览代码

Merge pull request #1 from nextzhou/master

fix TypeOf(nil) panic
Tao Wen 7 年之前
父节点
当前提交
58118c1ea9
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      reflect2.go

+ 3 - 0
reflect2.go

@@ -150,6 +150,9 @@ func (cfg *frozenConfig) TypeOf(obj interface{}) Type {
 }
 
 func (cfg *frozenConfig) Type2(type1 reflect.Type) Type {
+	if type1 == nil {
+		return nil
+	}
 	cacheKey := uintptr(unpackEFace(type1).data)
 	typeObj, found := cfg.cache.Load(cacheKey)
 	if found {