From e4e7e10e58986a004706eb2fd92e0c75540230b1 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 20 Mar 2018 11:38:36 +0900 Subject: [PATCH] ing --- reflect/type.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 reflect/type.go diff --git a/reflect/type.go b/reflect/type.go new file mode 100644 index 0000000..f57ee99 --- /dev/null +++ b/reflect/type.go @@ -0,0 +1,23 @@ +package reflect + +import ( + "reflect" +) + +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() +} + +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() +}