Skip to content

Instantly share code, notes, and snippets.

@BK1031
Created July 16, 2024 08:38
Show Gist options
  • Save BK1031/1e76c807a2740fa6c01463dc245427cc to your computer and use it in GitHub Desktop.
Save BK1031/1e76c807a2740fa6c01463dc245427cc to your computer and use it in GitHub Desktop.
singlestore-go-bookstore model/order.go CalculateTotal helper function
func (o *Order) CalculateTotal() {
o.Total = 0
for _, item := range o.Items {
o.Total += item.Book.Price * float64(item.Quantity)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment