type Config struct {
Listen string `json:"listen" toml:"listen"`
UserAPIURL string `json:"userapisrv" toml:"userAPIURL"`
SecretKey string `json:"secret_key" toml:"secret_key"`
AuthorityUrl string `json:"authorityapisrv" toml:"authority_url"`
ResourceKey string `json:"resource_key" toml:"resource_key"`
}
c := &Config{}
cvalue := reflect.ValueOf(c)
l := cvalue.Elem().NumField()
c := &Config{}
cType := reflect.TypeOf(c)
cValue := reflect.ValueOf(c)
structLen := cValue.Elem().NumField()
structMap := make(map[string]string,structLen)
for i := 0
field := cType.Elem().Field(i)
jsonName := field.Tag.Get("json")
structMap[jsonName] = field.Name
}
原文链接:https://www.f2er.com/go/187080.html