我有一个像这样的表单 html:
<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" />
我想要Bind()这样的表格struct:
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][]"`
}
但是如果我打印我Bind()之后的结果:POST
u := new(UserFrom)
if err = c.Bind(u); err != nil {
return
}
log.Println(u)
这个糟糕的输出:
&{email@mail.tld pwdpwdpwd [] [word1 word2]}
Tags []Tag结构中的行UserFrom不起作用
如果你尝试更改Tags []Tag为Tags Tag我有一个很好的最后一个条目
&{email@mail.tld pwdpwdpwd {tag3 3} [word1 word2]}
我想要这个输出:
&{email@mail.tld pwdpwdpwd [{tag1 1} {tag2 2} {tag3 3}] [word1 word2]}
你知道这个问题吗?
Echo Doc 绑定()
蛊毒传说
相关分类