card_id/common/data/grades.go

32 lines
493 B
Go
Raw Normal View History

2022-04-13 07:48:22 +00:00
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
}