From 64ce44652943cca57e51a685ea5bed1448ab9d7c Mon Sep 17 00:00:00 2001 From: Kushal Dwivedi Date: Sun, 26 Jul 2026 14:20:30 +0000 Subject: [PATCH] fix(key): check element instead of slice length in StringsWithShadows StringsWithShadows used "len(vals) == 0" inside a for-range loop over vals, which is always false when the loop body executes (the loop never runs on empty slices). This meant empty string values were passed through to strings.Split and produced spurious blank entries in results. Changed to iterate with "for _, v := range vals" and check "if v == \"\"" to properly skip individual empty values. Signed-off-by: Kushal Dwivedi --- key.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/key.go b/key.go index 800d04a..5ebcc5b 100644 --- a/key.go +++ b/key.go @@ -543,12 +543,11 @@ func (k *Key) Strings(delim string) []string { func (k *Key) StringsWithShadows(delim string) []string { vals := k.ValueWithShadows() results := make([]string, 0, len(vals)*2) - for i := range vals { - if len(vals) == 0 { + for _, v := range vals { + if v == "" { continue } - - results = append(results, strings.Split(vals[i], delim)...) + results = append(results, strings.Split(v, delim)...) } for i := range results {