type Config struct {
Listen @H_404_9@string `json:"listen" toml:"listen"`
UserAPIURL @H_404_9@string `json:"userapisrv" toml:"userAPIURL"`
SecretKey @H_404_9@string `json:"secret_key" toml:"secret_key"`
AuthorityUrl @H_404_9@string `json:"authorityapisrv" toml:"authority_url"`
ResourceKey @H_404_9@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