Skip to content

Instantly share code, notes, and snippets.

@Brunty
Last active June 12, 2016 11:39
Show Gist options
  • Save Brunty/da7a9bbc8b07318887635f8f8c0b0600 to your computer and use it in GitHub Desktop.
Save Brunty/da7a9bbc8b07318887635f8f8c0b0600 to your computer and use it in GitHub Desktop.
Style opinion time - which do you prefer? 1 or 2
type Money struct {
isoCode string
symbol string
value int
}
type Product struct {
name string
price Money
}
// 1
var productCollection = []Product{{"Playstation 4", Money{"GBP", "£", 45000}}}
// 2
var alternativeProductCollection = []Product{{name: "Playstation 4", price: Money{isoCode: "GBP", symbol: "£", value: 45000}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment