Golang list of structs
Published: Wednesday, Apr 15, 2015 Last modified: Monday, Dec 9, 2024
Assuming:
type Prop struct {
Type string
Price float64
}
This …
var props []Prop
props = append(props, Prop{"test", 4000})
props = append(props, Prop{"foo", 2313})
props = append(props, Prop{"bar", 2313})
same as:
props := []Prop{{"test", 4000}, {"foo", 2313}, {"bar", 2313}}
same as:
var props = []Prop{{"test", 4000}, {"foo", 2313}, {"bar", 2313}}