its not working properly now. When I added form:"-" to my field, the field is still being assigned a value regardless of whether I use Bind or ShouldBind.

go 1.21 github.com/gin-gonic/gin v1.9.1

type Astruct struct {
    Aa string  `form:"-" json:"aa"`
    Bb *string `form:"-" json:"bb"`
}

func Init(r *gin.Engine) {

    api := r.Group("/api")
    {
        api.GET("/ping", func(c *gin.Context) {
            c.JSON(http.StatusOK, "pong")
        })

        api.POST("/test", func(ctx *gin.Context) {
            var a Astruct
            ctx.Bind(&a)
            fmt.Println(a.Aa)
            fmt.Println(*a.Bb)
            ctx.AbortWithStatus(http.StatusOK)
        })
    }
}
POST http://127.0.0.1:9527/api/test
Content-Type: application/json

{
    "aa": "a",
    "bb": "b"
}
a
b
2023-09-05T01:30:16.577+0800    DEBUG   utils/logger.go:43  gin {"method": "POST", "path": "/api/test", "status": 200, "ip": "127.0.0.1", "elapsed": "243.845µs"}

Originally posted by @hotcoffie in https://github.com/gin-gonic/gin/issues/1733#issuecomment-1705569584

Comment From: filbertmangiri

2 weeks and no responses, BUMP

I'm also facing this problem..

Comment From: zanmato

In your example you are POSTing json which is still being bound via json:"aa". form is for form-data requests