darccio / mergo

Mergo: merging Go structs and maps since 2013
BSD 3-Clause "New" or "Revised" License
2.89k stars 271 forks source link

Boolean not empty #166

Closed vasilevkirill closed 2 years ago

vasilevkirill commented 4 years ago

hi im use this code

type Interface struct {
    Name            string
    Enabled         bool
    AutoNegotiation bool
    Speed           int
    FullDuplex      bool
    FlowControlTx   bool
    FlowControlRx   bool
}

newInterface := Interface{
     Name:    "SDWAN-CLIENT-878",
     Enabled: false,
}
oldInterface := Interface{
    Name:            "OriginalName",
    Enabled:         true,
    AutoNegotiation: true,
    Speed:           1000,
    FullDuplex:      true,
    FlowControlTx:   true,
    FlowControlRx:   false,
}
if err := mergo.Merge(&newInterface, oldInterface); err != nil {
    log.Panic(err)
}
log.Printf("%+v",newInterface)

Log Printing {Name:SDWAN-CLIENT-878 Enabled:true AutoNegotiation:true Speed:1000 FullDuplex:true FlowControlTx:true FlowControlRx:false}

I am waiting Field Enabled equal false same as in the variable newInterface

it's possible in mergo?

thanks.

xscode-auto-reply[bot] commented 4 years ago

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

yyong37 commented 3 years ago

issue131_test maybe help you.