When getting the values and shadows of a key, if there are no values at all, StringsWithShadows will return an array with an empty string. This does not seem like the right behaviour.
I would expect StringsWithShadows to return an empty array if there are no values. The documentation says that ValueWithShadows returns the raw value so there is a case to be made for it to return an empty string, but I would argue it is more intuitive to return an empty array even there.
Something like this should be enough to fix it from what I can tell (it is good enough in my case at least)
diff --git a/key.go b/key.go
index 0302c29..2147974 100644
--- a/key.go
+++ b/key.go
@@ -113,6 +113,9 @@ func (k *Key) Value() string {
// ValueWithShadows returns raw values of key and its shadows if any.
func (k *Key) ValueWithShadows() []string {
if len(k.shadows) == 0 {
+ if k.value == "" {
+ return []string{}
+ }
return []string{k.value}
}
vals := make([]string, len(k.shadows)+1)
When getting the values and shadows of a key, if there are no values at all, StringsWithShadows will return an array with an empty string. This does not seem like the right behaviour.
I would expect StringsWithShadows to return an empty array if there are no values. The documentation says that ValueWithShadows returns the raw value so there is a case to be made for it to return an empty string, but I would argue it is more intuitive to return an empty array even there.
Something like this should be enough to fix it from what I can tell (it is good enough in my case at least)