Skip to content

goanalysis_metalinter: SA9002: runtime error: index out of range [2] with length 1 #1730

Closed
@Juneezee

Description

@Juneezee

Thank you for creating the issue!

  • 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).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.36.0 built from 6c25d06 on 2021-01-26T13:14:05Z
Config file
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory
Go environment
$ go version && go env
go version go1.15.8 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jun/.cache/go-build"
GOENV="/home/jun/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jun/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jun/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jun/Desktop/log/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build684445965=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/jun/Desktop/log /home/jun/Desktop /home/jun /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (name|compiled_files|exports_file|files|imports|deps|types_sizes) took 169.662991ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 18.217401ms 
INFO [linters context/goanalysis] analyzers took 2.471184931s with top 10 stages: buildir: 1.59844417s, fact_purity: 87.463008ms, inspect: 76.516578ms, ctrlflow: 75.431944ms, printf: 74.303308ms, fact_deprecated: 45.799404ms, ineffassign: 37.402104ms, S1038: 25.86167ms, S1019: 16.784328ms, bools: 16.056652ms 
WARN [linters context] Panic: SA9002: package "log" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [2] with length 1: goroutine 826 [running]:
runtime/debug.Stack(0xf548ce, 0x3c, 0xc0037768d0)
	/opt/hostedtoolcache/go/1.15.6/x64/src/runtime/debug/stack.go:24 +0x9f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc001039ad0)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:508 +0x1be
panic(0xe3fe80, 0xc0033fc5a0)
	/opt/hostedtoolcache/go/1.15.6/x64/src/runtime/panic.go:969 +0x1b9
honnef.co/go/tools/staticcheck.CheckNonOctalFileMode.func1(0x105e760, 0xc005b760c0)
	/home/runner/go/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:2815 +0x77c
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc000cbc660, 0xc001045538, 0x1, 0x1, 0xc0010f7d48)
	/home/runner/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0xa2
honnef.co/go/tools/code.Preorder(...)
	/home/runner/go/pkg/mod/honnef.co/go/[email protected]/code/code.go:481
honnef.co/go/tools/staticcheck.CheckNonOctalFileMode(0xc005dd88f0, 0x95de16a0, 0x16b0b60, 0xc009672a78, 0x2)
	/home/runner/go/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:2834 +0xcc
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc001039ad0)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:590 +0xa83
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:512 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0011d0140, 0xea714d, 0x6, 0xc001045770)
	/home/runner/work/golangci-lint/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x50
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc001039ad0)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:511 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc00b307960, 0xc001039ad0)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:1059 +0x65
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:1054 +0x305 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: SA9002: package "log" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [2] with length 1 
INFO [linters context/goanalysis] analyzers took 163.34508ms with top 10 stages: buildir: 101.323504ms, U1000: 62.021576ms 
INFO [runner] processing took 36.739µs with stages: max_same_issues: 2.934µs, autogenerated_exclude: 2.375µs, nolint: 2.374µs, exclude-rules: 1.956µs, skip_files: 1.956µs, severity-rules: 1.956µs, sort_results: 1.956µs, cgo: 1.886µs, path_prettifier: 1.886µs, max_per_file_from_linter: 1.886µs, path_prefixer: 1.886µs, filename_unadjuster: 1.886µs, path_shortener: 1.885µs, skip_dirs: 1.816µs, max_from_linter: 1.467µs, diff: 1.466µs, identifier_marker: 1.397µs, exclude: 1.397µs, source_code: 1.397µs, uniq_by_line: 977ns 
INFO [runner] linters took 2.537529046s with stages: goanalysis_metalinter: 2.318229714s, unused: 218.999923ms 
ERRO Running error: goanalysis_metalinter: SA9002: package "log" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [2] with length 1 
INFO Memory: 29 samples, avg is 182.9MB, max is 275.7MB 
INFO Execution took 2.735348132s

I'm trying to add golangci-lint to the open-source Go project phuslu/log but the linter returns a runtime error.

The author of the project @phuslu was trying to run golangci-lint on GitHub Actions and the job failed as well, as shown by the job logs here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesRelates to an upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions