From c01ac072c63dc70f30476853a938795e8bf102c2 Mon Sep 17 00:00:00 2001 From: Shirong Lu <73147033+happysnaker@users.noreply.github.com> Date: Fri, 3 Jul 2026 16:44:11 +0800 Subject: [PATCH] fix: handle String() round-trip in Set() for stringToString String() wraps the output in [...], but Set() was not stripping those brackets before parsing. This caused round-trip failures when the output of String() (e.g. [x=[]]) was passed back to Set(), resulting in keys like '[x' instead of 'x'. Fixes #413 --- string_to_string.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/string_to_string.go b/string_to_string.go index 518e1366..24ecee18 100644 --- a/string_to_string.go +++ b/string_to_string.go @@ -24,6 +24,10 @@ func newStringToStringValue(val map[string]string, p *map[string]string) *string // Set updates the flag value from the given string, adding additional mappings or updating existing ones. func (s *stringToStringValue) Set(val string) error { var ss []string + // Support round-trip from String() output, which wraps the value in [...] + if strings.HasPrefix(val, "[") && strings.HasSuffix(val, "]") { + val = val[1 : len(val)-1] + } n := strings.Count(val, "=") switch n { case 0: