1. 代码:
package mainimport ("github.com/gin-gonic/gin""net/http")func main() {router := gin.Default()// Query string parameters are parsed using the existing underlying request object.// The request responds to a url matching: /welcome?firstname=Jane&lastname=Doe// 网址输入: localhost:8080/welcome?firstname=Jane&lastname=Doerouter.GET("/welcome", func(c *gin.Context) {firstname := c.DefaultQuery("firstname", "Guest")lastname := c.Query("lastname") // shortcut for c.Request.URL.Query().Get("lastname")c.String(http.StatusOK, "Hello %s %s", firstname, lastname)})router.Run(":8080")}
2. 在网址输入
http://localhost:8080/welcome?firstname=Jane&lastname=%E6%99%BA%E5%8B%87

