32 lines
493 B
Go
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
|
|
}
|