Zero number being ignored
mauricioabreu opened this issue · comments
Given this example:
package main
import (
"fmt"
"github.com/imdario/mergo"
)
type I struct {
A int
B int
}
func main() {
dst := I{A: 0, B: 0}
src := I{A: 1, B: 1}
mergo.Map(&dst, src)
fmt.Printf("%+v\n", &dst)
}
Output:
&{A:1 B:1}
How can I make the 0
to be replaced?
Thanks for opening a new issue. The team has been notified and will review it as soon as possible.
For urgent issues and priority support, visit https://xscode.com/imdario/mergo
@mauricioabreu false
is the zero value for bool
so it is IMO correct that mergo acts that way. You have the option WithOverwriteWithEmptyValue
to include zero values also to overwrite.
@imdario thank you!