要使用的 linter 可以作为命令行选项传递给 golangci-lint 程序。查看https://golangci-lint.run/usage/linters/以了解可用 linters 的概述。 太多的命令行选项会让生活变得一团糟。请改用配置文件。一个好的起点是https://golangci-lint.run/usage/configuration/#config-file。
With GoLand, you can also use yourgolangci-lint configuration filesto check your code in your CI pipeline and run the same linters in the IDE. Browse: use the file browser to select the path to thegolangci-lintexecutable.
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml # https://golangci-lint.run/usage/configuration/ run: timeout: 30s sort-results: true linters: fast: false presets: - bugs - complexity - unused enable: - misspell linters-settings: govet: check-shadowing...
1. 背景golangci-lint的 官方文档和golangci-lint help命令对命令行参数的说明都不完善,升级了golangci-lint之后,之前的--skip-files参数不可用了,通过官网和help命令查询新的应该怎么配,返回的不直观,可以通…
.golangci.toml .golangci.json 在golangci-lint 官方文档 https://golangci-lint.run/usage/configuration/#config-file 中,提供了一个示例配置文件,非常地详细,在这其中包含了所有支持的选项、描述和默认值。 使用pre-commit hook 在项目开发中,我们都会使用到 git,因此我们可以将代码静态检查放在一个 git ...
运行golangci-lint run 就会对当前文件夹下的文件进行静态检测。 run 其它参数 --fix 自动修复对应的 linter 报告 --disable-all 关闭所有linter 常见配置 golangci-lint配置部分如下: # Options for analysis running.run:# See the dedicated "run" documentation section.option:value# output configuration optio...
Remove gosimple from the enable section, as it is no longer supported in newer versions of golangci-lint. The other linters can be left. Without these changes, golangci-lint fails with errors. Loca...
2. Golangci-lint (1)安装golangci-lint 代码语言:text AI代码解释 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1 golangci-lint --version
在golangci-lint 官方文档 https://golangci-lint.run/usage/configuration/#config-file 中,提供了一个示例配置文件,非常地详细,在这其中包含了所有支持的选项、描述和默认值。 使用pre-commit hook 在项目开发中,我们都会使用到 git,因此我们可以将代码静态检查放在一个 git 触发点上,而不用每次写完代码手动去...
太多的命令行选项会让生活变得一团糟。请改用配置文件。一个好的起点是https://golangci-lint.run/usage/configuration/#config-file。 通过修改配置文件来调整 linter 的行为。您的团队可能会发现,如果函数超过 60 行或 40 条语句,并且行长超过 120 个字符,那么它仍然具有可读性。