template-monorepo/.golangci.yml

149 lines
3.0 KiB
YAML
Raw Normal View History

2026-05-19 13:15:18 +00:00
# golangci-lint v2 — Gateway 專案
# 參考https://golangci-lint.run/docs/configuration/
# 預設集「standard」= errcheck + govet + ineffassign + staticcheck + unused取代已棄用的 golint
# 再啟用社群常見的品質 / 安全 / 風格 linter並關閉過度吵雜的規則。
version: "2"
run:
timeout: 5m
tests: true
modules-download-mode: readonly
go: "1.26"
output:
formats:
text:
print-linter-name: true
colors: true
linters:
default: standard
enable:
# 錯誤與 context
- bodyclose
- contextcheck
- copyloopvar
- errname
- errorlint
- noctx
# 安全
- gosec
# 風格revive 為 golint 的現代替代)
- revive
- misspell
- unconvert
- whitespace
- gocritic
- goconst
- predeclared
# 測試
- testifylint
- thelper
# HTTP / API 常見
- rowserrcheck
- sloglint
disable:
- exhaustruct
- varnamelen
- wrapcheck
- nlreturn
- wsl
- wsl_v5
- dupl
- depguard
- tagliatelle
- ireturn
- funlen
- gochecknoglobals
- gochecknoinits
settings:
gosec:
excludes:
- G104
gocritic:
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- hugeParam
- rangeValCopy
- whyNoLint
revive:
severity: warning
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-naming
- name: exported
arguments:
- disableStutteringCheck
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: var-declaration
- name: var-naming
disabled: true
- name: package-comments
disabled: true
- name: comment-spacings
disabled: true
errcheck:
check-type-assertions: true
check-blank: true
staticcheck:
checks:
- all
- -ST1000
- -ST1003
- -ST1016
2026-05-20 13:03:59 +00:00
# go-zero conf uses `json:",optional"` for optional fields; staticcheck
# mis-reports it as an unknown json option, so suppress globally.
- -SA5008
2026-05-19 13:15:18 +00:00
exclusions:
generated: lax
warn-unused: true
presets:
- comments
- common-false-positives
- std-error-handling
- legacy
rules:
- path: _test\.go
linters:
- gosec
- errcheck
- funlen
- gocyclo
- cyclop
- path: internal/types/types\.go
linters:
- revive
- gocritic
paths:
- generate/doc-generate
- docs/openapi
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- generate/doc-generate
issues:
max-issues-per-linter: 0
max-same-issues: 0