
var (
mu sync.Mutex
items []Product
vatRate = 10.0
order Order
)
type Product struct {
NameOfProduct string
PriceOfProduct float32
}
type Order struct {
Items []Product
}
func init() {
items = make([]Product, 100)
}
func AddItemToShoppingCart(item Product) {
items = append(items, item)
}
func RemoveItemFromShoppingCart(nameOfItem string) bool {
mu.Lock()
defer mu.Unlock()
for i, item := range items {
if item.NameOfProduct == nameOfItem {
items = append(items[:i], items[i+1:]...)
}
}
}