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
golangci-lint run panics when trying to generate diagnostic message for final line of file. The code which generates the line number seems to go out of bounds.
The example below shows a 10 line example, if instead we add another blank line at the end making it 11 lines I don't get a panic and get the output:
main.go:11:1: File is not properly formatted (gofumpt)
^
Where you can see it generates the output for line 11 which now exists in the file.
Version of golangci-lint
$ golangci-lint --version
# golangci-lint has version 1.63.2 built with go1.23.4 from 15412b30 on 2025-01-02T12:43:20
Configuration
linters:
disable-all: trueenable:
- gofumpt
Go environment
$ go version && go envgo version go1.23.4 darwin/arm64GO111MODULE=''GOARCH='arm64'GOBIN=''GOCACHE='/Users/bian/Library/Caches/go-build'GOENV='/Users/bian/Library/Application Support/go/env'GOEXE=''GOEXPERIMENT=''GOFLAGS=''GOHOSTARCH='arm64'GOHOSTOS='darwin'GOINSECURE=''GOMODCACHE='/Users/bian/go/pkg/mod'GONOPROXY=''GONOSUMDB=''GOOS='darwin'GOPATH='/Users/bian/go'GOPRIVATE=''GOPROXY='https://proxy.golang.org,direct'GOROOT='/opt/homebrew/Cellar/go/1.23.4/libexec'GOSUMDB='sum.golang.org'GOTMPDIR=''GOTOOLCHAIN='local'GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.4/libexec/pkg/tool/darwin_arm64'GOVCS=''GOVERSION='go1.23.4'GODEBUG=''GOTELEMETRY='local'GOTELEMETRYDIR='/Users/bian/Library/Application Support/go/telemetry'GCCGO='gccgo'GOARM64='v8.0'AR='ar'CC='cc'CXX='c++'CGO_ENABLED='1'GOMOD='/Users/bian/code/lint-test/go.mod'GOWORK=''CGO_CFLAGS='-O2 -g'CGO_CPPFLAGS=''CGO_CXXFLAGS='-O2 -g'CGO_FFLAGS='-O2 -g'CGO_LDFLAGS='-O2 -g'PKG_CONFIG='pkg-config'GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/dt/w56r82l955v2r8yndkc5p2lc0000gn/T/go-build1485231540=/tmp/go-build -gno-record-gcc-switches -fno-common'
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -vINFO golangci-lint has version 1.63.2 built with go1.23.4 from 15412b30 on 2025-01-02T12:43:20ZINFO [config_reader] Config search paths: [./ /Users/bian/code/lint-test /Users/bian/code /Users/bian /Users /]INFO [config_reader] Used config file .golangci.yamlINFO [lintersdb] Active 1 linters: [gofumpt]INFO [loader] Go packages loading at mode 8199 (name|compiled_files|files) took 89.19125msINFO [runner/filename_unadjuster] Pre-built 0 adjustments in 194.416µsINFO [linters_context/goanalysis] analyzers took 103.957µs with top 10 stages: gofumpt: 89.666µs, typecheck: 14.291µsERRO [runner] Panic: gofumpt: package "main" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 11 (should be < 10): goroutine161 [running]:runtime/debug.Stack() runtime/debug/stack.go:26 +0x64github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1() github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:50 +0x21cpanic({0x101943620?, 0x1400067c1e0?}) runtime/panic.go:785 +0x124go/token.(*File).LineStart(0x0?, 0x1015cdc40?) go/token/position.go:232 +0x178github.com/golangci/golangci-lint/pkg/golinters/internal.toDiagnostic(0x14000169140, {0xb, 0xb, {0x0, 0x0, 0x0}}, 0x0) github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:254 +0x5cgithub.com/golangci/golangci-lint/pkg/golinters/internal.ExtractDiagnosticFromPatch(0x1400067a000, 0x14001190000, {0x14000f1a900, 0x82}, 0x1400058e180) github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:245 +0x334github.com/golangci/golangci-lint/pkg/golinters/gofumpt.runGofumpt(0x1400058e180, 0x1400067a000, {0x101b3f780, 0x1026206a0}, {{0x1400060ff60, 0x8}, {0x0, 0x0}, 0x0}) github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:89 +0x324github.com/golangci/golangci-lint/pkg/golinters/gofumpt.New.func1.1(0x1000000000a?) github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:52 +0x48github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(0x14000ff9608, 0x1400067a000) github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182 +0xd0github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0x14000ff9608) github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0x97cgithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x14001047c20, {0x1015c35d1, 0x7}, 0x140004c6730) github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x100f88520?) github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x70github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0x14000ff9608) github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:83 +0xaccreated by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 80 github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x174WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gofumpt: package "main" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 11 (should be < 10)INFO [runner] processing took 1.249µs with stages: max_same_issues: 375ns, cgo: 167ns, exclude: 125ns, skip_dirs: 125ns, max_from_linter: 83ns, invalid_issue: 42ns, skip_files: 42ns, path_prettifier: 42ns, identifier_marker: 42ns, exclude-rules: 42ns, filename_unadjuster: 41ns, path_shortener: 41ns, diff: 41ns, source_code: 41ns, uniq_by_line: 0s, severity-rules: 0s, nolint: 0s, max_per_file_from_linter: 0s, fixer: 0s, path_prefixer: 0s, autogenerated_exclude: 0s, sort_results: 0sINFO [runner] linters took 540.458µs with stages: goanalysis_metalinter: 492.792µsERRO Running error: can't run linter goanalysis_metalintergoanalysis_metalinter: gofumpt: package "main" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 11 (should be < 10)INFO Memory: 3 samples, avg is 27.4MB, max is 27.4MBINFO Execution took 101.097875ms
A minimal reproducible example or link to a public repository
Welcome
typecheck
section of the FAQ.Description of the problem
golangci-lint run
panics when trying to generate diagnostic message for final line of file. The code which generates the line number seems to go out of bounds.The example below shows a 10 line example, if instead we add another blank line at the end making it 11 lines I don't get a panic and get the output:
Where you can see it generates the output for line 11 which now exists in the file.
Version of golangci-lint
Configuration
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: