You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using cgo, I receive false positives from nlreturn. It is saying return with no blank line before for lines with defer or return when these lines call C functions. Adding a newline does not remove the issue. The problem with return lines does not happen always, and I was unable to replicate it in the example.
Version of golangci-lint
$ golangci-lint --versiongolangci-lint has version 2.0.2 built with go1.24.1 from 2b224c2c on 2025-03-25T21:36:18Z
Configuration
-E nlreturn
Go environment
$ go version && go envgo version go1.24.0 darwin/arm64AR='ar'CC='clang'CGO_CFLAGS='-O2 -g'CGO_CPPFLAGS=''CGO_CXXFLAGS='-O2 -g'CGO_ENABLED='1'CGO_FFLAGS='-O2 -g'CGO_LDFLAGS='-O2 -g'CXX='clang++'GCCGO='gccgo'GO111MODULE=''GOARCH='arm64'GOARM64='v8.0'GOAUTH='netrc'GOBIN=''GOCACHE='/Users/emrehn/Library/Caches/go-build'GOCACHEPROG=''GODEBUG=''GOENV='/Users/emrehn/Library/Application Support/go/env'GOEXE=''GOEXPERIMENT=''GOFIPS140='off'GOFLAGS=''GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/50/f2qw2dqn6dv5hsq9mfk7_zlw0000gp/T/go-build117157792=/tmp/go-build -gno-record-gcc-switches -fno-common'GOHOSTARCH='arm64'GOHOSTOS='darwin'GOINSECURE=''GOMOD='/Users/emrehn/Documents/git/test-nlreturn/go.mod'GOMODCACHE='/Users/emrehn/go/1.24.0/pkg/mod'GONOPROXY=''GONOSUMDB=''GOOS='darwin'GOPATH='/Users/emrehn/go/1.24.0'GOPRIVATE=''GOPROXY='https://proxy.golang.org,direct'GOROOT='/Users/emrehn/.goenv/versions/1.24.0'GOSUMDB='sum.golang.org'GOTELEMETRY='local'GOTELEMETRYDIR='/Users/emrehn/Library/Application Support/go/telemetry'GOTMPDIR=''GOTOOLCHAIN='auto'GOTOOLDIR='/Users/emrehn/.goenv/versions/1.24.0/pkg/tool/darwin_arm64'GOVCS=''GOVERSION='go1.24.0'GOWORK=''PKG_CONFIG='pkg-config'
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -vINFO golangci-lint has version 2.0.2 built with go1.24.1 from 2b224c2c on 2025-03-25T21:36:18Z INFO [config_reader] Config search paths: [./ /Users/emrehn/Documents/git/test-nlreturn /Users/emrehn/Documents/git /Users/emrehn/Documents /Users/emrehn /Users /] INFO maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined INFO [goenv] Read go env for 10.982667ms: map[string]string{"GOCACHE":"/Users/emrehn/Library/Caches/go-build", "GOROOT":"/Users/emrehn/.goenv/versions/1.24.0"} INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused] INFO [loader] Go packages loading at mode 8767 (imports|compiled_files|deps|exports_file|files|name|types_sizes) took 267.376375ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.793375ms INFO [linters_context/goanalysis] analyzers took 878.248092ms with top 10 stages: buildir: 585.437248ms, fact_deprecated: 60.726375ms, printf: 47.304998ms, ctrlflow: 38.757214ms, SA5012: 32.662958ms, fact_purity: 28.669753ms, nilness: 26.778172ms, inspect: 25.80021ms, typedness: 25.015751ms, tokenfileanalyzer: 1.35475ms INFO [runner] processing took 1.33µs with stages: max_same_issues: 250ns, exclusion_rules: 208ns, exclusion_paths: 208ns, path_absoluter: 167ns, path_shortener: 166ns, nolint_filter: 83ns, path_relativity: 42ns, source_code: 42ns, filename_unadjuster: 41ns, max_from_linter: 41ns, generated_file_filter: 41ns, invalid_issue: 41ns, fixer: 0s, path_prettifier: 0s, sort_results: 0s, diff: 0s, severity-rules: 0s, cgo: 0s, max_per_file_from_linter: 0s, uniq_by_line: 0s INFO [runner] linters took 565.383125ms with stages: goanalysis_metalinter: 565.337042ms 0 issues.INFO File cache stats: 0 entries of total size 0B INFO Memory: 10 samples, avg is 131.5MB, max is 243.9MB INFO Execution took 846.381667ms
A minimal reproducible example or link to a public repository
Welcome
typecheck
section of the FAQ.How did you install golangci-lint?
Brew
Description of the problem
When using cgo, I receive false positives from
nlreturn
. It is sayingreturn with no blank line before
for lines withdefer
orreturn
when these lines call C functions. Adding a newline does not remove the issue. The problem withreturn
lines does not happen always, and I was unable to replicate it in the example.Version of golangci-lint
Configuration
-E nlreturn
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Validation
Supporter
The text was updated successfully, but these errors were encountered: