Im a newbie in golang. I am trying to validate a yaml structure
prof:
res:
- ed:
app:
conf:
For that i have read the yaml file using ioutil, then converted it to map string interface. I tried 1) looping over map interface 2) converting it to json string using marshal and then looping but couldn't achieve it.
Any help will be appreciated. Thanks
yfile, err1 := ioutil.ReadFile("C:/Users/212764682/user.yaml")
data := make(map[string]interface{})
err := yaml.Unmarshal(yfile, &data)
Tried iterating like this
for key, value := range data {
if key == "prof" {
for key2, value2 := range value.(map[string]interface{}) {
if key2 == "res" {
for key3, value3 := range value2.(map[string]interface{}) {
if key3 == "ed" {
for key4, value4 := range value3.(map[string]interface{}) {
if key4 == "app" {
for key5 := range value4.(map[string]interface{}) {
if key5 == "conf" {
fmt.Println("valid format")
}
}
}
}
}
}
}
}
}
}