68 lines
1.5 KiB
YAML
68 lines
1.5 KiB
YAML
# golangci-lint 配置文件
|
|
# 详细文档: https://golangci-lint.run/usage/configuration/
|
|
|
|
run:
|
|
timeout: 5m
|
|
tests: true
|
|
modules-download-mode: readonly
|
|
|
|
output:
|
|
formats:
|
|
- format: colored-line-number
|
|
print-issued-lines: true
|
|
print-linter-name: true
|
|
sort-results: true
|
|
|
|
linters:
|
|
enable:
|
|
# 默认启用的 linters
|
|
- gosimple # 简化代码
|
|
- ineffassign # 检查无效赋值
|
|
- staticcheck # 静态检查
|
|
- unused # 检查未使用的代码
|
|
|
|
# 额外启用的 linters
|
|
- gofmt # 检查格式化
|
|
- goimports # 检查导入顺序
|
|
- misspell # 检查拼写错误
|
|
- gosec # 安全检查
|
|
- unconvert # 检查不必要的类型转换
|
|
- gocyclo # 检查代码复杂度
|
|
- goconst # 检查可以提取为常量的字符串
|
|
- whitespace # 检查空白符
|
|
|
|
linters-settings:
|
|
gocyclo:
|
|
min-complexity: 15
|
|
|
|
gosec:
|
|
excludes:
|
|
- G404 # 允许使用 math/rand
|
|
|
|
gofmt:
|
|
simplify: true
|
|
|
|
goimports:
|
|
local-prefixes: es-demo
|
|
|
|
issues:
|
|
exclude-dirs:
|
|
- vendor
|
|
exclude-use-default: false
|
|
max-issues-per-linter: 0
|
|
max-same-issues: 0
|
|
|
|
exclude-rules:
|
|
# 测试文件中允许一些宽松的规则
|
|
- path: _test\.go
|
|
linters:
|
|
- errcheck
|
|
- gosec
|
|
- gocyclo
|
|
- goconst
|
|
|
|
# 允许在 main 包中使用 fmt.Printf
|
|
- path: main\.go
|
|
linters:
|
|
- forbidigo
|