Don't Unmarshal field with underline
sitnikovv opened this issue · 0 comments
sitnikovv commented
package main
import (
"fmt"
"github.com/ghodss/yaml"
)
type MyStruct struct {
Exchange string `yaml:"exchange"`
RoutingKey string `yaml:"routing_key"`
Role string `yaml:"role"`
}
func main() {
var mystr MyStruct
yamlstr := `
exchange: "data1"
routing_key: "data2"
role: data3
`
yaml.Unmarshal([]byte(yamlstr), &mystr)
fmt.Printf("%+v\n", mystr)
}
out:
{Exchange:data1 RoutingKey: Role:data3}