将 URL 查询参数解析为结构时,'form' 是可接受的结构标记吗?

Is 'form' an acceptable struct tag to use when parsing URL query parameters into a struct?

我有一个 GET 请求函数,它使用 gin.Context 接受查询参数。我目前正在使用 context.ShouldBindQuery(&myQueryParamStruct) 将这些查询参数传递到一个看起来像

的结构中
type myParams struct {
    Color string `form:"color"`
    Size  int    `form:"size"`
}

我的问题是使用表单标签执行此操作时会出现问题(因为我在技术上不使用表单,我使用的是查询参数),是否有更好的结构标签用于此目的?

form是正确的标签,你不用担心。

另请注意,html 使用 GET 请求发送的表单是在查询字符串中而不是正文中发送的。此外,查询字符串和表单主体都具有 application/x-www-form-urlencoded 格式。