Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGoreflection basicsSingle-choice MCQ

Using reflection, you try to set a struct field's value but `reflect.Value.Set` panics with 'reflect: reflect.Value.Set using unaddressable value'. Given the code, what fixes it?

type Config struct{ Name string } c := Config{} v := reflect.ValueOf(c) v.FieldByName("Name").SetString("x") // panics