Explorar el Código

Merge pull request #1 from nextzhou/master

fix TypeOf(nil) panic
Tao Wen hace 8 años
padre
commit
58118c1ea9
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  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 {