-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
83 lines (77 loc) · 3.27 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ----------------------------------------------------------------------
# .golangci.yml
# Opinionated configuration for golangci-lint, aligned with
# commonly accepted Go best practices (similar to Google’s style).
# ----------------------------------------------------------------------
# Reference: https://golangci-lint.run/usage/configuration/
#
# Key points:
# 1. Many of these linters come from the Staticcheck suite or
# are recommended in the Go community for code cleanliness.
# 2. Some linters (like 'godot', 'godox', 'revive') add extra
# style checks. Feel free to disable if too strict for your
# project.
# 3. 'stylecheck' is a modern replacement for 'golint' with
# similar checks but fewer false positives.
# ----------------------------------------------------------------------
run:
# If you want to restrict linting to only certain directories,
# you can specify them here:
# dirs:
# - ./app
#
# Timeout for the entire linter run (5 minutes).
timeout: 5m
issues:
# Exclude or skip directories for vendor, generated code, etc.:
skip-dirs:
- vendor
- third_party
# You can also exclude specific issues by regex if needed:
exclude-rules:
# Ignore HTTP capitalization warnings from stylecheck
- linters:
- stylecheck
text: "ST1003: (func|type) .* should be .*HTTP"
linters:
# We enable a core set of recommended linters for Go.
enable:
- govet # Go's vet tool for catching suspicious constructs
- staticcheck # Comprehensive static analysis (includes SA, ST, etc.)
- gosimple # Suggest simpler code constructs
- ineffassign # Detects assignments to variables that are never used
- errcheck # Checks for unchecked errors
- goconst # Finds repeated strings that could be constants
- revive # A flexible, configurable linter similar to golint
- stylecheck # Style rules (capitalization of acronyms, etc.)
- gocyclo # Checks function/method complexity
- godot # Ensures comments end with a period
- godox # Highlights unfinished code (TODO, FIXME, etc.)
- gofmt # Standard Go formatting checks
- misspell # Correct commonly misspelled English words
# Disable any linters that are redundant or produce noise for your project:
disable:
# 'typecheck' is often redundant with govet + staticcheck
- typecheck
linters-settings:
govet:
# (Optional) For advanced checks, you can uncomment:
# checkshadow: true
gocyclo:
# The default threshold is 30; 15-20 is common to encourage simpler functions.
min-complexity: 15
godot:
# If you only want to enforce comment endings on exported declarations,
# set this to "true":
scope-only: false
# revive can be tuned via .revive.toml; minimal usage can be kept inline:
revive:
ignore-generated-header: true
# You could specify a path to a custom config:
# config: .revive.toml
stylecheck:
# stylecheck enforces naming conventions and doc comments.
# If you have short test functions, you can exclude them:
# checks: ["ST1005", "ST1020"] # etc.
# If your repository has code generation or specific “ignore” patterns,
# refine skip-dirs, exclude, or exclude-rules above.