diff --git a/utils/reflect.go b/utils/reflect.go new file mode 100644 index 0000000..1b0f11d --- /dev/null +++ b/utils/reflect.go @@ -0,0 +1,21 @@ +package utils + +import "reflect" + +func ReflectMakeNew(t reflect.Type) interface{} { + retptr := reflect.New(t) + sval := retptr.Elem().Interface() + return sval +} + +type TagMap map[string] string + +func ReflectTagMap(t reflect.Type) map[string] TagMap{ + ret := map[string] TagMap{} + num := t.NumField() + for i := 0;i < num;i++{ + s := t.Field(i).Tag + ret[string(s)] = t.Field(i).Name + } + return ret +} \ No newline at end of file