+3
-4
@@ -516,11 +516,10 @@ func scopeStruct(v reflect.Value, name string) (target, bool, error) {
|
|||||||
l := len(path)
|
l := len(path)
|
||||||
path = append(path, i)
|
path = append(path, i)
|
||||||
f := t.Field(i)
|
f := t.Field(i)
|
||||||
if f.PkgPath != "" {
|
if f.Anonymous {
|
||||||
// only consider exported fields
|
|
||||||
} else if f.Anonymous {
|
|
||||||
walk(v.Field(i))
|
walk(v.Field(i))
|
||||||
} else {
|
} else if f.PkgPath == "" {
|
||||||
|
// only consider exported fields
|
||||||
fieldName, ok := f.Tag.Lookup("toml")
|
fieldName, ok := f.Tag.Lookup("toml")
|
||||||
if !ok {
|
if !ok {
|
||||||
fieldName = f.Name
|
fieldName = f.Name
|
||||||
|
|||||||
@@ -931,3 +931,19 @@ func TestIssue287(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.Equal(t, expected, v)
|
require.Equal(t, expected, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue508(t *testing.T) {
|
||||||
|
type head struct {
|
||||||
|
Title string `toml:"title"`
|
||||||
|
}
|
||||||
|
type text struct {
|
||||||
|
head
|
||||||
|
}
|
||||||
|
|
||||||
|
var b = []byte(`title = "This is a title"`)
|
||||||
|
|
||||||
|
t1 := text{}
|
||||||
|
err := toml.Unmarshal(b, &t1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, "This is a title", t1.head.Title)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user