Suppose we have the following go code
type SectionType int
const (
Header SectionType = iota
Footer
Body
)
var sectionTypeNames = map[string]SectionType{
"header": Header
"footer": Footer
"body": Body
}
type Page struct {
Sections: []SectionType `yaml:"sections"`
}
And we have the following yaml
page1:
- header
- body
Is there a way to get goyaml to convert the strings of "header" and "body" into their respective int constant types (as defined in sectionTypeNames
map) we deserializing the Page
struct?