go-yaml / yaml

YAML support for the Go language.
Other
6.88k stars 1.05k forks source link

Unmarshaller panics on anonymous private fields #254

Open ghost opened 7 years ago

ghost commented 7 years ago
package main

import (
    "gopkg.in/yaml.v2"
)

type x struct {
    field string
}

type y struct {
    x
}

func main() {
    b := []byte(`
x:
  field: something
`)
    var Y y
    println(yaml.Unmarshal(b, &Y))
}
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method [recovered]
    panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
ghost commented 7 years ago

related: https://github.com/go-yaml/yaml/pull/253