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

Why does this reflection-based field set panic, and what change fixes it?

type Config struct{ Port int } func set(c Config) { v := reflect.ValueOf(c) v.FieldByName("Port").SetInt(8080) }