栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

vscode go开发staticcheck配置

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

vscode go开发staticcheck配置

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"
		]

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/907723.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号