Closed
Description
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've included all information below (version, config, etc).
- Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)
Description of the problem
The config file has lower priority than command-line options. If the same bool/string/int option is provided on the command-line and in the config file, the option from command-line will be used. Slice options (e.g. list of enabled/disabled linters) are combined from the command-line and config file.
https://golangci-lint.run/usage/configuration/
But, --disable-all
is not available as follows
# With config file
$ golangci-lint run --disable-all --fix -E gci
sample/sample.go:50:6: `get` is unused (deadcode)
func get(){}
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.40.0 built from (unknown, mod sum: "h1:MFueiIIh9Ri5yWLRu9RkrS0nd2F+x67zC7ISQR2Hta4=") on (unknown)
Config file
$ cat .golangci.yml
linters-settings:
gci:
local-prefixes: hogehogehoge # private repo
linters:
enable:
- govet
- errcheck
- staticcheck
- unused
- gosimple
- structcheck
- varcheck
- ineffassign
- deadcode
- typecheck
- gosec
- prealloc
- gocognit
- gci
Go environment
$ go version && go env
go version go1.16 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kenseinakada/Library/Caches/go-build"
GOENV="/Users/kenseinakada/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kenseinakada/go/1.14.4/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kenseinakada/go/1.14.4:/Users/kenseinakada/go/1.16.0"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/kenseinakada/.goenv/versions/1.16.0"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kenseinakada/.goenv/versions/1.16.0/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kenseinakada/workspace/website-server/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rw/7byjyh1d73qft75rrw2m9ns80000gn/T/go-build4039158151=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/kenseinakada/workspace/website-server /Users/kenseinakada/workspace /Users/kenseinakada /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 14 linters: [deadcode errcheck gci gocognit gosec gosimple govet ineffassign prealloc staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|exports_file|name|types_sizes|files|imports) took 1.293421628s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 6.338016ms
INFO [linters context/goanalysis] analyzers took 29.60776324s with top 10 stages: buildir: 19.072165637s, fact_deprecated: 1.424373534s, inspect: 1.349569079s, ctrlflow: 1.335017154s, printf: 1.219457416s, fact_purity: 1.204501138s, nilness: 1.175531984s, typedness: 1.040805289s, SA5012: 1.015641009s, gci: 87.24066ms
INFO [runner] Issues before processing: 2, after processing: 1
INFO [runner] Processors filtering stat (out/in): nolint: 2/2, uniq_by_line: 1/2, diff: 1/1, max_same_issues: 1/1, source_code: 1/1, path_shortener: 1/1, severity-rules: 1/1, filename_unadjuster: 2/2, path_prettifier: 2/2, skip_files: 2/2, exclude: 2/2, exclude-rules: 2/2, cgo: 2/2, identifier_marker: 2/2, max_per_file_from_linter: 1/1, path_prefixer: 1/1, sort_results: 1/1, skip_dirs: 2/2, autogenerated_exclude: 2/2, max_from_linter: 1/1
INFO [runner] processing took 1.943975ms with stages: identifier_marker: 468.501µs, nolint: 455.115µs, autogenerated_exclude: 338.451µs, filename_unadjuster: 292.429µs, source_code: 205.978µs, path_prettifier: 110.577µs, skip_dirs: 34.194µs, exclude-rules: 19.867µs, uniq_by_line: 3.963µs, cgo: 3.725µs, max_same_issues: 3.421µs, path_shortener: 3.101µs, max_from_linter: 1.38µs, max_per_file_from_linter: 762ns, sort_results: 584ns, diff: 549ns, skip_files: 469ns, exclude: 410ns, severity-rules: 341ns, path_prefixer: 158ns
INFO [runner] linters took 7.204543617s with stages: goanalysis_metalinter: 7.201490168s
database/migration.go:50:6: `get` is unused (deadcode)
func get(){}
^
INFO File cache stats: 1 entries of total size 1.6KiB
INFO Memory: 86 samples, avg is 510.7MB, max is 810.9MB
INFO Execution took 8.57519375s
The following expects that only gci will be executed
$ golangci-lint run -v --disable-all --fix -E gci
INFO [config_reader] Config search paths: [./ /Users/kenseinakada/workspace/website-server /Users/kenseinakada/workspace /Users/kenseinakada /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 14 linters: [deadcode errcheck gci gocognit gosec gosimple govet ineffassign prealloc staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (deps|imports|name|types_sizes|compiled_files|exports_file|files) took 1.329004717s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.546664ms
INFO [linters context/goanalysis] analyzers took 0s with no stages
INFO [runner] Issues before processing: 2, after processing: 1
INFO [runner] Processors filtering stat (out/in): severity-rules: 1/1, cgo: 2/2, max_same_issues: 1/1, max_from_linter: 1/1, path_prettifier: 2/2, skip_dirs: 2/2, sort_results: 1/1, exclude: 2/2, nolint: 2/2, source_code: 1/1, filename_unadjuster: 2/2, skip_files: 2/2, identifier_marker: 2/2, diff: 1/1, max_per_file_from_linter: 1/1, path_shortener: 1/1, path_prefixer: 1/1, autogenerated_exclude: 2/2, exclude-rules: 2/2, uniq_by_line: 1/2
INFO [runner] processing took 916.904µs with stages: nolint: 321.54µs, source_code: 245.116µs, autogenerated_exclude: 169.157µs, path_prettifier: 82.059µs, identifier_marker: 34.541µs, skip_dirs: 31.607µs, exclude-rules: 13.256µs, uniq_by_line: 7.289µs, filename_unadjuster: 2.527µs, max_same_issues: 2.435µs, path_shortener: 1.636µs, cgo: 1.554µs, max_from_linter: 1.056µs, max_per_file_from_linter: 778ns, skip_files: 509ns, diff: 490ns, sort_results: 484ns, severity-rules: 355ns, exclude: 335ns, path_prefixer: 180ns
INFO [runner] linters took 238.8876ms with stages: goanalysis_metalinter: 237.801844ms
INFO fixer took 0s with no stages
database/migration.go:50:6: `get` is unused (deadcode)
func get(){}
^
INFO File cache stats: 1 entries of total size 1.6KiB
INFO Memory: 17 samples, avg is 71.9MB, max is 72.1MB
INFO Execution took 1.586652491s
Code example or link to a public repository
// go file with dead code
func get(){}