How to handle key conflicts when using mapstructure:",squash" ?
Author: dangquyittCreated Jun 13, 2024Updated Jun 21, 2024
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]Source: mitchellh/mapstructure