Last active
May 12, 2025 10:09
-
-
Save cristaloleg/dc29ca0ef2fb554de28d94c3c6f6dc88 to your computer and use it in GitHub Desktop.
An opinionated golangci-lint config (right version™)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ golangci-lint run --config=~/.golangci.yml ./... > lint.txt | |
version: "2" | |
run: | |
# default concurrency is a available CPU number | |
concurrency: 8 | |
go: "" | |
build-tags: | |
- integration | |
modules-download-mode: readonly | |
# exit code when at least one issue was found, default is 1 | |
issues-exit-code: 1 | |
# include test files or not, default is true | |
tests: true | |
# Allow multiple parallel golangci-lint instances running. | |
# If false (default) - golangci-lint acquires file lock on start. | |
allow-parallel-runners: false | |
output: | |
path-prefix: "" | |
linters: | |
enable: | |
- asasalint | |
- asciicheck | |
- bidichk | |
- bodyclose | |
- canonicalheader | |
- contextcheck | |
- copyloopvar | |
- durationcheck | |
- errname | |
- errorlint | |
- exptostd | |
- gocritic | |
- godot | |
- gomoddirectives | |
- gosec | |
- misspell | |
- nakedret | |
- nilerr | |
- nilnesserr | |
- nilnil | |
- noctx | |
- nolintlint | |
- prealloc | |
- predeclared | |
- reassign | |
- revive | |
- rowserrcheck | |
- sqlclosecheck | |
- staticcheck | |
- tagliatelle | |
- testableexamples | |
- thelper | |
- tparallel | |
- unconvert | |
- unparam | |
- usestdlibvars | |
- usetesting | |
- wastedassign | |
disable: | |
- containedctx | |
- cyclop | |
- decorder | |
- depguard | |
- dogsled | |
- dupl | |
- dupword | |
- err113 | |
- errchkjson | |
- exhaustive | |
- exhaustruct | |
- forbidigo | |
- forcetypeassert | |
- funlen | |
- ginkgolinter | |
- gocheckcompilerdirectives | |
- gochecknoglobals | |
- gochecknoinits | |
- gocognit | |
- goconst | |
- gocyclo | |
- godox | |
- goheader | |
- gomodguard | |
- goprintffuncname | |
- grouper | |
- importas | |
- interfacebloat | |
- intrange | |
- ireturn | |
- lll | |
- loggercheck | |
- maintidx | |
- makezero | |
- mirror | |
- mnd | |
- musttag | |
- nestif | |
- nlreturn | |
- nonamedreturns | |
- nosprintfhostport | |
- paralleltest | |
- promlinter | |
- protogetter | |
- recvcheck | |
- spancheck | |
- testifylint | |
- testpackage | |
- varnamelen | |
- whitespace | |
- wrapcheck | |
- wsl | |
- zerologlint | |
settings: | |
errcheck: | |
check-type-assertions: true | |
check-blank: true | |
exclude-functions: | |
- io/ioutil.ReadFile | |
- io.Copy(*bytes.Buffer) | |
- io.Copy(os.Stdout) | |
gocritic: | |
disabled-checks: | |
- hugeParam | |
- rangeExprCopy | |
- rangeValCopy | |
enabled-tags: | |
- diagnostic | |
- experimental | |
- opinionated | |
- performance | |
- style | |
govet: | |
disable: | |
- fieldalignment | |
nakedret: | |
max-func-lines: 1 | |
tagliatelle: | |
case: | |
rules: | |
avro: snake | |
bson: camel | |
json: snake | |
mapstructure: kebab | |
xml: camel | |
yaml: snake | |
exclusions: | |
generated: lax | |
presets: | |
- comments | |
- common-false-positives | |
- legacy | |
- std-error-handling | |
paths: | |
- third_party$ | |
- builtin$ | |
- examples$ | |
issues: | |
max-issues-per-linter: 0 | |
max-same-issues: 0 | |
new: false | |
fix: false | |
formatters: | |
enable: | |
- gofmt | |
- gofumpt | |
- goimports | |
exclusions: | |
generated: lax | |
paths: | |
- third_party$ | |
- builtin$ | |
- examples$ |
Strange, but after I lint the code all works like sharm (i download the source file of course)...
Also, on golangci-lint has version 1.42.1 built from 54f4301 on 2021-09-04T14:39:09Z
there few warnings:
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive.
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner. Replaced by exportloopref.
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
PS Thanks for sharing!
Ah, ok
interfacer <...> archived by the owner.
- but still works!golint <...> archived by the owner.
- but still works!scopelint <...> archived by the owner. Replaced by exportloopref.
- still works but can be replaced, thanks.
(Have updated the file)
I'm curious what your v2 config looks like these days!
@StevenACoffman will push today. Thank you for the reminder 😉
@cristaloleg im interested too
@StevenACoffman @melekhine done. Took more time than I expected :D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm, wut?
golangci-lint run --config=~/.golangci.yaml
works fine 👀