-
Notifications
You must be signed in to change notification settings - Fork 382
Open
Labels
featureCategorizes as related to a new featureCategorizes as related to a new feature
Description
Describe the feature
Currently, ValueWithShadows() ignores empty values after PR #316.
This breaks workflows where an empty assignment is semantically meaningful (e.g., systemd unit files use empty values to reset previous assignments, see https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html: "If the empty string is assigned to this option, the list of commands to start is reset, prior assignments of this option will have no effect.").
Describe the solution you'd like
Introduce a new opt‑in option to preserve empty shadow values:
opts := ini.LoadOptions{
AllowShadows: true,
PreserveEmptyShadows: true, // new option
}
f, _ := ini.Load(data, opts)
vals := f.Section("Service").Key("Environment").ValueWithShadows()
// Expected: []string{"FOO=bar", ""}
Default behavior would remain unchanged to avoid breaking existing users.
Describe alternatives you've considered
Add a new field to LoadOptions, an enum named EmptyValueHandling, with three possible values:
- Ignore – current default behavior, empty values are skipped.
- Preserve – empty values are kept in ValueWithShadows().
- IgnorePrevious – when an empty value is encountered, all previous values for the key are discarded (systemd‑style reset).
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
featureCategorizes as related to a new featureCategorizes as related to a new feature