gin中只绑定url查询字符串
package main import ( "github.com/gin-gonic/gin" "log" ) type Person struct{ Name string `form:"name" binding:"required" json:"name"` Address string `form:"address" binding:"required" json:"address"` } func main() { router := gin.Default() router.Any("/testing", startPage) router.Run() } func startPage(c *gin.Context) { var person Person if err := c.ShouldBindQuery(&person); err == nil { log.Println("---only bind by query string") log.Println(person.Name) log.Println(person.Address) } else { log.Println(err) } c.String(200, "Success") }