mapstructure
mapstructure copied to clipboard
How to handle key conflicts when using mapstructure:",squash" ?
type Order struct {
Id string
}
type User struct {
Id string
Order Order `mapstructure:",squash"`
}
result := map[string]interface{}{}
mapstructure.Decode(User{
Id: "userId",
Order: Order{
Id: "orderId",
},
}, &result)
log.Println(result)
Output: map[Id:orderId]
Expected: map[Id:userId Order.Id:orderId]