vscode go开发staticcheck配置

vscode go开发staticcheck配置,第1张

vscode go开发staticcheck配置 staticcheck简介

它是针对go的静态检查工具,文档地址如下
https://staticcheck.io/docs

命令行使用staticcheck检查

检查当前目录
~/go1.15_path/bin/staticcheck
输出示例如下:

filtermgr.go:764:2: redundant return statement (S1023)
ip_filter.go:29:23: should omit comparison to bool constant, can be simplified to !force (S1002)
netlink.go:62:7: receiver name should be a reflection of its identity; don't use generic names such as "this" or "self" (ST1006)
netlink.go:78:7: receiver name should be a reflection of its identity; don't use generic 
privilege_ip.go:22:5: don't use Yoda conditions (ST1017)

可支持的检查类型在这儿可以查到
https://staticcheck.io/docs/checks

配置检查的具体项
检查所有类型,但是不包含ST1020,S1*,星号是通配符
~/go1.15_path/bin/staticcheck -checks all,-ST1020,-S1*

vscode配置

命令行参数弄对了,在vscode里面就好配置了。
设置里面go插件的Lint Tool选择stataiccheck,然后设置Lint Flags,json中输入如下

"go.lintFlags": [
			"-checks",
			"all,-ST1020,-ST1003,-ST1006"
		]

注意点就是一个空格分隔即表示一个参数。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/995402.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存