Skip to content

Instantly share code, notes, and snippets.

@cristaloleg
Last active May 12, 2025 10:09
Show Gist options
  • Save cristaloleg/dc29ca0ef2fb554de28d94c3c6f6dc88 to your computer and use it in GitHub Desktop.
Save cristaloleg/dc29ca0ef2fb554de28d94c3c6f6dc88 to your computer and use it in GitHub Desktop.
An opinionated golangci-lint config (right version™)
# $ 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$
@cristaloleg
Copy link
Author

cristaloleg commented May 12, 2025

@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