-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci.yml
More file actions
62 lines (49 loc) · 2.83 KB
/
.golangci.yml
File metadata and controls
62 lines (49 loc) · 2.83 KB
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
# golangci-lint configuration file
# Reference: https://golangci-lint.run/usage/configuration/
# Config format version
version: "2"
run:
# Timeout for analysis, e.g. 30s, 5m.
# 5m is usually enough for medium-sized projects.
timeout: 5m
# Include test files in the analysis.
tests: true
# Build tags to include integration tests or specific build modes.
build-tags:
- integration
# Ensure modules are not downloaded during linting (CI friendly).
modules-download-mode: readonly
linters:
enable:
# --- 1. Critical Bugs & Static Analysis (Must Pass) ---
- govet # Official Go tool. Reports suspicious constructs (printf args, shadow variables, etc.).
- errcheck # Forces checking of all returned errors. Essential for robust code.
- staticcheck # The "Gold Standard" for Go. Detects bugs, simplifications, and useless code.
- unused # Checks for unused constants, variables, functions, and types.
- ineffassign # Detects when assignments to existing variables are not used (often a logic bug).
# --- 2. Modern Go Idioms & Best Practices ---
- errorlint # Enforces Go 1.13+ error wrapping (errors.Is/As) instead of direct comparisons.
- bodyclose # Checks whether HTTP response body is closed successfully (prevents memory leaks).
- noctx # Finds HTTP requests sent without a context.Context (critical for timeouts/cancellation).
- unconvert # Removes unnecessary type conversions (cleans up code).
- nolintlint # Reports ill-formed or unnecessary //nolint directives.
# --- 3. Code Style & Complexity ---
- revive # Fast, configurable, extensible, flexible, and beautiful drop-in replacement for golint.
- goconst # Finds repeated strings that could be replaced by a constant.
- gocritic # Provides diagnostics that check for bugs, performance, and style issues. Very opinionated.
- gocyclo # Computes and checks the cyclomatic complexity of functions.
- gosec # Inspects source code for security problems (SQL injection, weak crypto, etc.).
# --- 4. Performance (Optional) ---
- gosec # Inspects source code for security problems (SQL injection, weak crypto, etc.).
# --- 5. Performance (Optional) ---
- prealloc # Finds slice declarations that could potentially be preallocated.
issues:
# Maximum issues count per one linter. Set to 0 to disable.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable.
max-same-issues: 0
# Show only new issues: if there are unstaged changes or untracked files, only those issues are reported.
new: false
# Try to automatically fix issues (like imports or simple style stuff).
# Run `golangci-lint run --fix` manually instead of enabling this permanently in CI.
fix: false