我们建议至少使用以下的linters ,因为我们认为它们有助于发现最常见的问题,并且在没有不必要的规定的情况下为代码质量建立一个高标准:
- errcheck to ensure that errors are handled
- goimports to format code and manage imports
- golint to point out common style mistakes(注意:此仓库连接已经过时)
- govet to analyze code for common mistakes
- staticcheck to do various static analysis checks
实例:下载errcheck(win10 环境)
Lint Runners
我们推荐 golangci-lint 作为Go代码的首选lint运行器,主要是因为它在大型代码库中的性能以及同时配置和使用多个规范lint的能力。
这个repo 有个例子.golangci.yml 配置文件,包含推荐的linters 和设置。
golangci-lint有various linters 可供使用。建议将上面的linter作为一个基本集合,并且我们鼓励团队添加任何对他们的项目有意义的附加linters 。