This question already has an answer here:
- Go Unmarshaling YAML into struct 2 answers
Im trying to convert a yaml data into a struct and print it. The output I get for this program is empty.
package main
import (
"fmt"
"gopkg.in/yaml.v2"
)
type example struct {
variable1 string
variable2 string
}
func main() {
var a example
yaml.Unmarshal([]byte("variable1: asd
variable2: sdcs"), &a)
fmt.Println(a.variable1)
}
</div>