no message
parent
b1564b91ff
commit
3507633164
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue