fix: Map decode issues #20
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/map-decode-panics-and-duplicate-sections"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolve #15 #16
decodeFileToMapReflect always built an untyped map[string]any tree and copied it straight into the destination map with SetMapIndex, so any target shape other than exactly map[string]any (e.g. map[string]string, map[string]int, or map[string]map[string]string) panicked with an unhandled reflect.Value.SetMapIndex type mismatch instead of Unmarshal returning an error. Duplicate keys promoted to []string hit the same panic whenever the destination expected a scalar. Rewrite it to inspect the destination's element type: interface{} keeps the existing dynamic map[string]any behavior, map element types now decode one inner map per section (reusing setFieldValue for per-value conversion, and reusing the same duplicate-key error struct decoding already returns), and any other element type returns a descriptive error instead of reaching the panic.fix/map-decode-panics-and-duplicate-sectionsto fix: Map decode issues