I have a Form html like :
<input name="email"type="email" />
<input name="password"type="password" />
<input name="tags[name][]"type="text" />
<input name="tags[count][]"type="number" />
<input name="tags[name][]"type="text" />
<input name="tags[count][]"type="number" />
<input name="tags[name][]"type="text" />
<input name="tags[count][]"type="number" />
<input name="freeword[]"type="text" />
<input name="freeword[]"type="text" />
I want to Bind()
this form with my struct
like :
type UserFrom struct {
Email string `json:"email" form:"email" query:"email"`
Password string `json:"password" form:"password" query:"password"`
Tags []Tag
Free []string `json:"freeword[]" form:"freeword[]" query:"freeword[]"`
}
type Tag struct {
Name string `json:"tags[name][]" form:"tags[name][]" query:"tags[name][]"`
Count string `json:"tags[count][]" form:"tags[count][]" query:"tags[count][]"`
}
But if i print the result of Bind()
after POST
i have :
u := new(UserFrom)
if err = c.Bind(u); err != nil {
return
}
log.Println(u)
This bad Output :
&{email@mail.tld pwdpwdpwd [] [word1 word2]}
The row Tags []Tag
in UserFrom
struct does not work
If y try to change Tags []Tag
to Tags Tag
i have a good last entry
&{email@mail.tld pwdpwdpwd {tag3 3} [word1 word2]}
I want this output :
&{email@mail.tld pwdpwdpwd [{tag1 1} {tag2 2} {tag3 3}] [word1 word2]}
do you have an idea of the problem ?