fix: allow empty StringToString values#486
Conversation
|
Maintainer context: this intentionally scopes the empty-value semantics to |
So it seems you read this comment and then promptly ignored it? :) Changing the behavior of empty slices vs slices with a single empty value (vs potentially other, also conflicting, behavior that I haven't thought of) is explicitly not in scope for 1.x. Contributions to the 1.x codebase to change this behavior will not be accepted. Figuring out exactly which changes are backward compatible or not, without potentially breaking users' expectations four levels down the dependency tree, is just more complicated than it's worth. I recently created an experimentation bed for v2 in #482; I will make sure that whatever implementation for slice-valued flags we end up there solve this better. |
Summary
--flag=/flag.Set("")forStringToStringto clear the map to an empty map instead of returning a formatting errorWhy
Issue #312 asks for a way to override a non-empty default map with an explicit empty value.
This change follows the same semantics already accepted for typed slice flags in #222 / #485:
That makes
StringToStringbehave like a real override channel instead of forcing callers to choose between "keep defaults" and "replace with at least one entry".Scope / compatibility
StringToStringStringArray/StringSlice/ other collection types here--flag=itself, so this uses syntax that currently errors rather than reinterpreting a previously valid non-empty valueTests
Added regression coverage for:
--s2s=Note: I did not run
go test/go buildlocally for this branch.