Skip to content

Incorrectly decode to embedded field #31

Open
@powerman

Description

@powerman

If same field exists both in parent and embedded struct and url.Values has value only for parent then decoder incorrect set embedded field to same value.

type Embed struct {
	A string
}
var data struct {
	A string
	Embed
}
form.NewDecoder().Decode(&data, url.Values{
	"A": {"one"},
})
fmt.Println(data.A, data.Embed.A)
// Output: one one

If we will add "Embed.A":{"two"} or keep only this one and remove "A": {"one"} then it'll work as expected.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions