配置管理 后台功能

This commit is contained in:
pixel
2020-01-13 15:25:03 +08:00
parent a53bf70f65
commit 838ac66660
7 changed files with 159 additions and 53 deletions

View File

@@ -1 +1,15 @@
package tools
import "reflect"
// 利用反射将结构体转化为map
func StructToMap(obj interface{}) map[string]interface{}{
obj1 := reflect.TypeOf(obj)
obj2 := reflect.ValueOf(obj)
var data = make(map[string]interface{})
for i := 0; i < obj1.NumField(); i++ {
data[obj1.Field(i).Name] = obj2.Field(i).Interface()
}
return data
}