Repository navigation
Circular linter warnings between errcheck and staticcheck when discarding channel output #6891
Welcome
How did you install golangci-lint?Other Description of the problemWhen using a channel which return errors, Version of golangci-lintgolangci-lint has version 2.15.0 built with go1.27.2 from Copr on 2026-10-17T00:00:00Z ConfigurationDetailsgolangci-lint run main.goGo environmentDetails$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/heathcliff/go/bin'
GOCACHE='/home/heathcliff/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/heathcliff/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3740643288=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/heathcliff/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/heathcliff/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib64/golang'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/heathcliff/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib64/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27.3'
GOWORK=''
PKG_CONFIG='pkg-config'Verbose output of runningDetails$ golangci-lint cache clean
$ golangci-lint run -v main.go
INFO golangci-lint has version 2.15.0 built with go1.27.2 from Copr on 2026-10-17T00:00:00Z
INFO [config_reader] Config search paths: [./ /home/heathcliff/repos/tmp /home/heathcliff/repos /home/heathcliff /home /]
INFO [goenv] Read go env for 2.910376ms: map[string]string{"GOCACHE":"/home/heathcliff/.cache/go-build", "GOROOT":"/usr/lib64/golang"}
INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 8767 (compiled_files|deps|exports_file|imports|name|types_sizes|files) took 31.296815ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 95.369µs
INFO [linters_context/goanalysis] analyzers took 4.206638ms with top 10 stages: ST1012: 268.322µs, fact_deprecated: 217.376µs, inspect: 214.772µs, ctrlflow: 188.021µs, fact_purity: 162.844µs, printf: 160.29µs, SA5012: 150.903µs, buildir: 144.831µs, nilness: 140.603µs, inline: 140.523µs
INFO [runner] Processors filtering stat (in/out): path_absoluter: 1/1, nolint_filter: 1/1, fixer: 1/1, uniq_by_line: 1/1, max_same_issues: 1/1, cgo: 1/1, invalid_issue: 1/1, generated_file_filter: 1/1, path_shortener: 1/1, severity-rules: 1/1, exclusion_paths: 1/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, source_code: 1/1, path_prettifier: 1/1, sort_results: 1/1, filename_unadjuster: 1/1, path_relativity: 1/1, exclusion_rules: 1/1, diff: 1/1
INFO [runner] processing took 59.219µs with stages: generated_file_filter: 19.987µs, nolint_filter: 18.805µs, source_code: 10.78µs, uniq_by_line: 3.677µs, path_relativity: 1.232µs, max_same_issues: 692ns, sort_results: 601ns, path_shortener: 491ns, max_from_linter: 481ns, cgo: 450ns, invalid_issue: 381ns, exclusion_rules: 340ns, diff: 201ns, path_prettifier: 200ns, path_absoluter: 200ns, exclusion_paths: 190ns, filename_unadjuster: 170ns, fixer: 141ns, max_per_file_from_linter: 120ns, severity-rules: 80ns
INFO [runner] linters took 4.817955ms with stages: goanalysis_metalinter: 4.716776ms
main.go:10:2: Error return value is not checked (errcheck)
<-res
^
1 issues:
* errcheck: 1
INFO File cache stats: 1 entries of total size 95B
INFO Memory: 2 samples, avg is 45.0MB, max is 49.0MB
INFO Execution took 39.354764msA minimal reproducible example or link to a public repositoryDetailspackage main
func main() {
res := make(chan error)
go func() {
res <- nil
}()
<-res
//_ = <-res
}Validation
🌱 Supporting the Maintainers |
Replies: 3 comments
|
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
|
Just to make it clear, i know i can (and did) suppress the linter warning for this with: //nolint:errcheck |
|
This comes from errcheck v1.30.0, which golangci-lint v2.15.0 bundles: it started reporting a bare receive from a channel whose element type is It is a known conflict. It was reported in kisielk/errcheck#294, and the staticcheck author said there that S1005 does not look at the channel element type yet and that he plans to fix it in dominikh/go-tools#1844 (still open, so no staticcheck release has it yet). Once that ships and golangci-lint picks it up, Until then there are two ways around it without Receive into a variable and discard that, which neither linter reports: err := <-res
_ = errOr keep version: "2"
linters:
exclusions:
rules:
- linters: [staticcheck]
text: "S1005"
source: '_ = <-'That rule also hides S1005 for Source, if you want it: reproduced with golangci-lint v2.15.0 (errcheck v1.30.0 per its go.mod) and Go 1.26 on your example, kisielk/errcheck#294, dominikh/go-tools#1844. |
This comes from errcheck v1.30.0, which golangci-lint v2.15.0 bundles: it started reporting a bare receive from a channel whose element type is
error(kisielk/errcheck#288), and its accepted "explicit discard" form_ = <-resis exactly what staticcheck's S1005 flags.It is a known conflict. It was reported in kisielk/errcheck#294, and the staticcheck author said there that S1005 does not look at the channel element type yet and that he plans to fix it in dominikh/go-tools#1844 (still open, so no staticcheck release has it yet). Once that ships and golangci-lint picks it up,
_ = <-reswill pass both linters.Until then there are two ways around it without
//nolint.Receive into a variable …