Programming/JAVA, C++, Go, Rust
Go 언어에서 reflect로 필드명과 값 획득 방법
Roiei
2023. 6. 20. 11:40
반응형
func getKeyValueFromConfig(reflectValue reflect.Value, options *scenario.RequestOptions) {
reflectType := reflectValue.Type()
for i := 0; i < reflectValue.NumField(); i++ {
field := reflectType.Field(i)
value := reflectValue.Field(i).Interface()
fmt.Printf("Field: %s, Value: %v\n", field.Name, value)
options.InputOptions[field.Name] = value
}
}
반응형