package main import ( "encoding/json" "path/filepath" "io/ioutil" ) type recipe struct { Title string Portions int Url string Steps []struct { Text string Ingredients []struct { Type string Amount any } } } func getRecipe(id string) (recipe, error) { r := recipe{} textpath := filepath.Join(config.Data, "recipes", id, "text") data, err := ioutil.ReadFile(textpath) if err != nil { return r, err } err = json.Unmarshal(data, &r) if err != nil { return r, err } return r, nil }