gin golang Invalid validation tag on field ‘AId‘

复制代码
结构体如下
Go 复制代码
type CreateParams struct {
    AId uint   `json:"a_id" binding:"required,"
    BId  uint   `json:"b_id" binding:"required,"
  
}

运行时报错:Invalid validation tag on field 'AId'

原因:在binding中,如果只有一个要求,不要加逗号,否则会逗号被当作一个词验证

修改:

Go 复制代码
type CreateParams struct {
    AId uint   `json:"a_id" binding:"required"
    BId  uint   `json:"b_id" binding:"required"
  
}
相关推荐
柳鲲鹏1 小时前
交叉编译:strip: Unable to recognise the format of the input file xx.c.o
linux·运维·服务器
QX_hao1 小时前
【Go】--数据类型
开发语言·后端·golang
h7997101 小时前
redis lua脚本(go)调用教程以及debug调试
redis·golang·lua
趣味编程1111 小时前
go的学习2---》并发编程
学习·golang·perl
Le1Yu1 小时前
微服务拆分以及注册中心
linux·运维·服务器
moxiaoran57532 小时前
nginx中proxy_pass配置
运维·服务器·nginx
weixin_379880922 小时前
.Net Core WebApi集成Swagger
java·服务器·.netcore
她说彩礼65万2 小时前
Asp.net core Kestrel服务器详解
服务器·后端·asp.net
ZLRRLZ3 小时前
【Linux操作系统】进程控制
linux·运维·服务器
qq762118224 小时前
Linux c 在内存中创建zip,最后写入测试
linux·运维·服务器