I have the following YML file called test.yml
user_name:Agent1
org_info:
first:hello
second:world
I tried to unmarshal test.yml
with the following golang code
package main
import (
"log"
"io/ioutil"
"gopkg.in/yaml.v2"
)
func main() {
content, _ := ioutil.ReadFile("./test.yml")
var t interface{}
yaml.Unmarshal(content, &t)
log.Println(t)
}
But the log.Println(t)
gives nil
. I reduced the test.yml
file to this:
user_name:Agent1
org_info:
But the log.Println(t)
still gives nil
.
How do I use golang to unmarshal a yaml file that has an unpredictable schema with fields that have no values or fields that lead to nested and indented sub fields?
Or is there another golang yaml parser I should be using?