Open bayaderpack opened 5 months ago
There is a problem with your usage, you should use BindQuery
or ShouldBindQuery
.
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
g := gin.Default()
g.GET("/hello", func(c *gin.Context) {
m := make(map[string]string)
if err := c.BindQuery(&m); err != nil {
c.String(http.StatusInternalServerError,"input data have error: %v",err)
return
}
c.String(http.StatusOK,"input data: %v",m["user"])
})
g.Run(":9000")
}
If you use c.Get
, you need to use your c.Set
in context
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
g := gin.Default()
g.GET("/hello", func(c *gin.Context) {
c.Set("user",999)
c.String(http.StatusOK,"user id: %d",c.GetInt("user"))
})
g.Run(":9000")
}
Description
I'm trying to use GetUint64 and GetUint but it returns 0
How to reproduce
Expectations
Actual result
Environment