util-go/reflect/type.go
2019-11-13 22:23:17 +09:00

24 lines
481 B
Go

package reflect
import "reflect"
// GetTypeInfo is function
func GetTypeInfo(t reflect.Type) (realType reflect.Type, pkgName string, name string) {
if reflect.Ptr == t.Kind() {
return GetTypeInfo(t.Elem())
}
return t, t.PkgPath(), t.Name()
}
// IsTypeKind is function
func IsTypeKind(t reflect.Type, kind reflect.Kind, removePtr bool) bool {
if reflect.Ptr == t.Kind() {
if removePtr {
return IsTypeKind(t.Elem(), kind, removePtr)
}
}
return kind == t.Kind()
}