golang struct tag value的语法错误

背景

在使用golang的struct tag进行json和db映射的时候,发现有这么一行和其它不一样,本以为是冒号或者分号中英文不对的问题,但是细细寻找一遍之后无果,这一行就一直报这个错误,很尴尬,明明和其它行的用法一样,但就是有这种警告,而且程序运行时也确实映射不到,最后找到了错误,是空格的tab的区别。。。。

没错,这里只能用空格,不能用tab。。。就是如此坑。。。。但是goland IDE早已帮你想到了解决办法,smart tab 哈哈,设置方法见最后一张图。

Bad syntax for struct tag value less… (⌘F1)
Inspection info: Verifies that struct tags conform to Go conventions.
According to these conventions, tag strings are a concatenation of optionally space-separated key:”value” pairs. Each key is a non-empty string consisting of non-control characters other than space (U+0020 ’ ‘), quote (U+0022 ‘”’), and colon (U+003A ‘:’). Each value is quoted using U+0022 ‘”’ characters and Go string literal syntax.
Also, checks that fields with tags are exported.

这里写图片描述

解决

这里写图片描述

然后删除中间的tab,再次敲tab就是4个空格了。done :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值