I'm new to Go and can't create a map of multiple structures
type ResultMap struct {
title string
shope Shope
}
type Shope struct {
title string
prices PriceModel
}
type PriceModel struct {
price, priceSale float64
}
I want to get a map like this with multiple shops:
{
"title": "Foo",
"shope": {
"title": "Matket_1",
"prices": {
"price": 100.5,
"priceSale": 99.5
}
},
"shope": {
"title": "Matket_2",
"prices": {
"price": 100.5,
"priceSale": 99.5
}
//...
//Market_3
//Market_4
}
I get the data from the loop and try to add it to the map:
for _, i := range shoplist {
priceList := ResultMap{
title: i,
shope: Shope{
title: i.shope,
prices: PriceModel{
price: i.price,
priceSale: i.priceSale,
},
},
// try
shope: Shope{
title: i.shope,
prices: PriceModel{
price: i.price,
priceSale: i.priceSale,
},
}
// errore
}
I realize that a list needs to be created somewhere, but I don't know exactly where to create it