Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion query/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error {
typ := val.Type()
for i := 0; i < typ.NumField(); i++ {
sf := typ.Field(i)
if sf.PkgPath != "" { // unexported
if sf.PkgPath != "" && !sf.Anonymous { // unexported
continue
}

Expand Down
13 changes: 13 additions & 0 deletions query/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ type D struct {
C string
}

type e struct {
B
C string
}

type F struct {
e
}

func TestValues_embeddedStructs(t *testing.T) {
tests := []struct {
in interface{}
Expand All @@ -216,6 +225,10 @@ func TestValues_embeddedStructs(t *testing.T) {
D{B: B{C: "bar"}, C: "foo"},
url.Values{"C": {"foo", "bar"}},
},
{
F{e{B: B{C: "bar"}, C: "foo"}}, // With unexported embed
url.Values{"C": {"foo", "bar"}},
},
}

for i, tt := range tests {
Expand Down