Skip to content

The config that panics on write

medium

LoadDefaults is supposed to return a config map with defaults applied, and callers then add their own keys. It compiles, it reads fine, and it panics the moment anyone writes to it. Fix it so the returned map is usable.

Signature

func LoadDefaults(overrides map[string]string) map[string]string

Examples

  • LoadDefaults(nil) → {"region":"eu-central-1","retries":"3"}
  • LoadDefaults(map[string]string{"retries":"5"}) → retries overridden to "5"
  • the returned map must accept new keys without panicking

Constraints

  • Defaults are region=eu-central-1 and retries=3
  • Any key in overrides wins over the defaults, including keys that are not defaults
  • Do not modify the overrides map the caller passed in