Skip to content

Instantly share code, notes, and snippets.

@manjeettahkur
Created June 1, 2022 01:57
Show Gist options
  • Save manjeettahkur/911d5d1b372e3f701cd9b0b0c4fb75e7 to your computer and use it in GitHub Desktop.
Save manjeettahkur/911d5d1b372e3f701cd9b0b0c4fb75e7 to your computer and use it in GitHub Desktop.
Code conventions, Practice and Tooling Group -- Linter Settings
linters-settings:
govet:
check-shadowing: true
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
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 2
ignore-tests: true
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- ifElseChain
- whyNoLint
gocyclo:
min-complexity: 20
gomnd:
settings:
mnd:
checks:
- argument
- case
- condition
- return
- operation
# assign is optional to enable
ignored-numbers: "100"
lll:
line-length: 140
misspell:
locale: UK
nolintlint:
allow-unused: false # report any unused nolint directives
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
require-explanation: false # don't require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
linters:
disable-all: true
enable:
# ESSENTIALS AND ENABLED BY DEFAULT
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
# BEGINNER GO DEV SLAYER PACK
- bodyclose
- dogsled
- dupl
# - errname enable if your version is +v1.42.0
- exportloopref
- forcetypeassert
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint # use "revive" instead of "golint" if you can, this is abandoned already!
- gomnd
- gosec
- lll
- misspell
- nakedret
- nilerr
- nolintlint
# - paralleltest enable this to enforce table driven tests fast with t.Parallel()
- predeclared
- stylecheck
- thelper
# - tparallel enable this to enforce correct usage of t.Parallel()
- unconvert
- unparam
- whitespace
# SQL PRESETS
# - execinquery enable if your version is +v1.46.0
- rowserrcheck
- sqlclosecheck
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude duplicates and type assertions in the tests
- path: _test\.go
linters:
- dupl
- forcetypeassert
# Exclude shadowing on common Go conventions
- linters:
- govet
text: "shadow: declaration of \"(err|ok|ctx)\""
# Exclude init from main.go files
- linters:
- gochecknoinits
path: main\.go
# Exclude lll issues for long lines with go:generate
- linters:
- lll
source: "^//go:generate "
run:
timeout: 4m
skip-dirs:
- bigquery
skip-files:
- lib/bad.go
rules:
- linters:
- dupl
severity: info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment