hello i am a begginer in golang and i am working on a shopping cart app, every time i try to excute the code it shows "first argument to append must be slice" here is the code package cart
type Cart struct {
items map[string]Item
}
type Item struct {
id string
name string
price float32
quantity int
}
func NewItem(i string, n string, p float32) Item {
return Item{
id: i,
name: n,
price: p,
quantity: 0,
}
}
func NewCart() Cart {
return Cart{
items: map[string]Item{}}
}
func (box *Cart) AddItem(item Item) []Item {
box.items = append(box.items, item)
return box.items
}
func main() {
utils.CreateLogger("shopping-cart")
shoppingCart := cart.NewCart()
item1 := cart.NewItem("potato121", "Potato", 10)
err := shoppingCart.AddItem(item1)
}