card_id/common/data/result.go
2022-04-13 18:09:58 -05:00

31 lines
422 B
Go

package data
import (
"os"
"gopkg.in/yaml.v3"
)
type Results []Result
type Result struct {
Id 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
}