spf13/viper
: )
type T struct {
val int `yaml:"with_underscore"`
}
func TestUnmarshal(t *testing.T) {
a := assert.New(t)
yamlExample := []byte(`a: 2
with_underscore: 1`)
viper.SetConfigType("yaml")
viper.ReadConfig(bytes.NewBuffer(yamlExample))
a.Equal(1, viper.GetInt("with_underscore"))
tmp := T{}
err := viper.Unmarshal(&tmp)
a.Nil(err)
a.Equal(1, tmp.val)
}
with_underscore
field didn't get unmarshaled into tmp
. is there anyway around this?