card_id/common/data/grades.go
2022-04-13 02:48:22 -05:00

32 lines
493 B
Go

package data
import (
"os"
"gopkg.in/yaml.v3"
)
type Grades []Grade
type Grade struct {
Grade int `yaml:"Grade"`
Rate float64 `yaml:"Rate0"`
SpecialTable int `yaml:"Special_Table"`
SpecialRate float64 `yaml:"Special_Rate"`
}
func NewGradesFromFile(path string) (Grades, error) {
out := []Grade{}
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
}