sprig
sprig copied to clipboard
Merging with zero 0 does not work
It seems like the value 0 is not merged properly. I have created the following test which currently fails.
func TestMergeZero(t *testing.T) {
dict := map[string]interface{}{
"src2": map[string]interface{}{
"h": 10,
},
"src1": map[string]interface{}{
"h": 0,
},
"dst": map[string]interface{}{},
}
tpl := `{{merge .dst .src1 .src2}}`
_, err := runRaw(tpl, dict)
if err != nil {
t.Error(err)
}
expected := map[string]interface{}{
"h": 0, // FAILS: I AM EXPECTING 0 BUT 10 IS WHAT I GET
}
assert.Equal(t, expected, dict["dst"])
}
Did I miss something?
This appears to be the intended behavior. merge
uses https://github.com/imdario/mergo under the hood which will overwrite zero values.