package main type Ingredient struct { Name string Parts []Ingredient Location string Notes []string } type RecipeIngredient struct { Ingredient Quantity int } type Recipe struct { Name string Parts []RecipeIngredient Notes []string } func NewRecipe(nm string) *Recipe { ret := Recipe{Name: nm} } func (r *Recipe) AddNote(nt string) { r.Notes = append(r.Notes, nt) } func (r *Recipe) AddIngredient(i *Ingredient, qty int) { for i := range r.Parts { if r.Parts[i].Name == i.Name { // This ingredient is already a party of the recipe r.Parts[i].Quantity += qty return } } ing := new(RecipeIngredient) ing.Name = i.Name ing.Parts = i.Parts ing.Location = i.Location ing.Quantity = qty ing.Notes = i.Notes r.Parts = append(r.Parts, ing) }