package data import ( "os" "gopkg.in/yaml.v3" ) type Results []Result type Result struct { Itemid int `yaml:"Itemid"` Name string `yaml:"Name"` Rate float64 `yaml:"Rate"` } func NewResultsFromFile(path string) (Results, error) { out := []Result{} bts, err := os.ReadFile(path) if err != nil { return nil, err } err = yaml.Unmarshal(bts, &out) if err != nil { return nil, err } return out, nil }