package cvdata import ( "fmt" utils "github.com/jesusperez/datautils" ) type TeachingType struct { Auth AuthInfoType `yaml:"auth" json:"auth"` Date string `yaml:"date" json:"date"` Title string `yaml:"title" json:"title"` Org string `yaml:"org" json:"org"` Location string `yaml:"location" json:"location"` Description []string `yaml:"description" json:"description"` } type Teaching struct { Teaching []TeachingType `yaml:"teaching" json:"teaching"` } type ShowTeachingType struct { Auth AuthInfoType `yaml:"auth" json:"auth"` Date bool `yaml:"date" json:"date"` Title bool `yaml:"title" json:"title"` Org bool `yaml:"org" json:"org"` Location bool `yaml:"location" json:"location"` Description bool `yaml:"description" json:"description"` } func (teaching *Teaching)Load(path string) ([]TeachingType, error) { d,file,errpath := utils.DecoderFromFile(path) if errpath != nil { return teaching.Teaching, errpath } defer file.Close() if err := d.Decode(&teaching); err != nil { fmt.Printf("Decode: %v", err) return teaching.Teaching, err } return teaching.Teaching, nil }