no message

master
DESKTOP-4RNDQIC\29019 2021-02-06 01:48:22 +08:00
parent b1564b91ff
commit 3507633164
1 changed files with 21 additions and 0 deletions

21
utils/reflect.go Normal file
View File

@ -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
}