Created
July 16, 2024 08:38
-
-
Save BK1031/1e76c807a2740fa6c01463dc245427cc to your computer and use it in GitHub Desktop.
singlestore-go-bookstore model/order.go CalculateTotal helper function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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