### BindQuery\\ShouldBindQuery(只限查询参数)
BindQuery\ShouldBindQuery函数只绑定查询参数,而不绑定POST数据。
我现在只BindQuery来试验,ShouldBindQuery我测试输出结果一样
~~~
package main
import "log"
import "github.com/gin-gonic/gin"
type Person struct {
Name string `form:"name"`
Address string `form:"address"`
}
func main() {
route := gin.Default()
route.Any("/testing", startPage)
route.Run(":8080")
}
func startPage(c *gin.Context) {
var person Person
if c.BindQuery(&person) == nil {
log.Println("====== Only Bind Query String ======")
log.Println(person.Name)
log.Println(person.Address)
}
c.String(200, "Success")
}
~~~