Skip to content

Instantly share code, notes, and snippets.

@julien-noblet
Created April 18, 2023 20:31
Show Gist options
  • Select an option

  • Save julien-noblet/96638ed6eb8a923cc41c9810b223c457 to your computer and use it in GitHub Desktop.

Select an option

Save julien-noblet/96638ed6eb8a923cc41c9810b223c457 to your computer and use it in GitHub Desktop.
my default .golangci.yml
linters-settings:
govet:
check-shadowing: true
enable:
- atomicalign
- timeformat
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
golint:
min-confidence: 0
gocyclo:
min-complexity: 20
maligned:
suggest-new: true
dupl:
threshold: 150
goconst:
min-len: 2
min-occurrences: 3
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-messages:
github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
misspell:
locale: US
lll:
line-length: 150
goimports:
local-prefixes: github.com/golangci/golangci-lint
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
#- commentedOutCode
# - hugeParam
#- wrapperFunc
#- dupImport # https://github.com/go-critic/go-critic/issues/845
#- ifElseChain
#- octalLiteral
funlen:
lines: 100
statements: 50
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: true # Report preallocation suggestions on for loops, false by default
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: true # Enforces newlines (or comments) after every multi-line function signature
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
strict-append: true
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
allow-assign-and-call: true
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow case blocks to end with a whitespace.
allow-case-traling-whitespace: true
# Allow declarations (var) to be cuddled.
allow-cuddle-declarations: false
exhaustruct:
exclude:
- 'guia2\.BySelector$'
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- cyclop
#- deadcode
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustruct
#- exhaustivestruct
- exportloopref
- funlen
- forbidigo
- forcetypeassert
- ginkgolinter
#- gci
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- goconst
- gocritic
- gocyclo
- godot
#- godox
# - goerr113
#- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
#- ifshort
- importas
- ineffassign
- interfacebloat
- ireturn
- lll
- loggercheck
- maintidx
- makezero
- misspell
- musttag
- nakedret
#- nilassign
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
#- structcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
#- unused
- usestdlibvars
#- varcheck
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
# don't enable:
# - gochecknoglobals
# - gocognit
# - gochecknoinits
# - prealloc
# - testpackage
run:
timeout: 5m
skip-dirs:
- test/testdata_etc
skip-files:
- internal/cache/.*_test.go
issues:
exclude-rules:
- path: _test.go
linters:
- lll
- gochecknoinits
- gocyclo
- funlen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment