Skip to content

Can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct #3592

Closed
@st6446

Description

@st6446

Welcome

  • 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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Bumping golangci-lint v1.51.1 from v.1.15.0, and execute golangci-lint. Then error happend.

full error log

olangci-lint run --timeout=5m
ERRO [runner] Panic: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct: goroutine 13826 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:102 +0x155
panic({0xf42840, 0xc00e441ed0})
        runtime/panic.go:884 +0x213
honnef.co/go/tools/analysis/lint.ExhaustiveTypeSwitch(...)
        honnef.co/go/tools@v0.4.0/analysis/lint/lint.go:234
honnef.co/go/tools/unused.(*graph).embeddedField(0xc0016df618, {0x131bcf0?, 0xc008bc8660?}, {0x132d4d8, 0xc008e00c60})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1413 +0x534
honnef.co/go/tools/unused.(*graph).read(0xc0016df618, {0x131c0b0?, 0xc0084fd200?}, {0x132d4d8, 0xc008e00c60})
        honnef.co/go/tools@v0.4.0/unused/unused.go:822 +0x14ed
honnef.co/go/tools/unused.(*graph).read(0xc0016df618, {0x131c0b0?, 0xc0084fd218?}, {0x132d4d8, 0xc008e00cc0})
        honnef.co/go/tools@v0.4.0/unused/unused.go:831 +0x156f
honnef.co/go/tools/unused.(*graph).namedType(0xc0016df618, 0x131bb88?, {0x131f720?, 0xc0084fd230?})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1516 +0x458
honnef.co/go/tools/unused.(*graph).decl(0xc0016df618, {0x131f360?, 0xc008bb1f80}, {0x0, 0x0})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1099 +0xa72
honnef.co/go/tools/unused.(*graph).entry(0xc0016df618)
        honnef.co/go/tools@v0.4.0/unused/unused.go:518 +0xc28
honnef.co/go/tools/unused.run(0xc00d199770)
        honnef.co/go/tools@v0.4.0/unused/unused.go:219 +0x245
github.com/golangci/golangci-lint/pkg/golinters.runUnused(0xc00d199770)
        github.com/golangci/golangci-lint/pkg/golinters/unused.go:61 +0x48
github.com/golangci/golangci-lint/pkg/golinters.NewUnused.func1(0xf82d00?)
        github.com/golangci/golangci-lint/pkg/golinters/unused.go:31 +0x2f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0015466e0)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:188 +0x9df
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:106 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00064f6d0, {0x10ccb49, 0x6}, 0xc00a96b748)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc008eec740?)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0015466e0)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct

Version of golangci-lint

$ golangci-lint --version
# Paste output here
golangci-lint has version 1.51.1 built from b87d2c19 on 2023-02-05T13:06:33Z

Configuration file

$ cat .golangci.yml
# paste output here
linters:
  enable:
    - stylecheck
    - nakedret
    - errorlint
    - exhaustive

Go environment

$ go version && go env
# paste output here
go version go1.20 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/username/.cache/go-build"
GOENV="/home/username/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/username/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/username/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/username/some/project/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 -m64 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1706252246=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here
INFO [config_reader] Config search paths: [./ /quipper/monorepo/shinkobetsu /quipper/monorepo /quipper / /home/quipper] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 11 linters: [errcheck errorlint exhaustive gosimple govet ineffassign nakedret staticcheck stylecheck typecheck unused] 
INFO [loader] Go packages loading at mode 575 (exports_file|files|imports|types_sizes|compiled_files|deps|name) took 331.667469ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 39.433136ms 
INFO [linters_context/goanalysis] analyzers took 1m3.942709123s with top 10 stages: buildir: 36.436634552s, exhaustive: 12.880620466s, inspect: 1.533070144s, fact_deprecated: 1.109119948s, unused: 1.092464815s, S1038: 1.029685396s, printf: 967.401536ms, ctrlflow: 839.557041ms, errorlint: 713.089538ms, fact_purity: 684.527637ms 
ERRO [runner] Panic: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct: goroutine 12323 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:102 +0x155
panic({0xf42840, 0xc0026ed320})
        runtime/panic.go:884 +0x213
honnef.co/go/tools/analysis/lint.ExhaustiveTypeSwitch(...)
        honnef.co/go/tools@v0.4.0/analysis/lint/lint.go:234
honnef.co/go/tools/unused.(*graph).embeddedField(0xc000eaf618, {0x131bcf0?, 0xc01260b320?}, {0x132d4d8, 0xc014392240})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1413 +0x534
honnef.co/go/tools/unused.(*graph).read(0xc000eaf618, {0x131c0b0?, 0xc013612d98?}, {0x132d4d8, 0xc014392240})
        honnef.co/go/tools@v0.4.0/unused/unused.go:822 +0x14ed
honnef.co/go/tools/unused.(*graph).read(0xc000eaf618, {0x131c0b0?, 0xc013612db0?}, {0x132d4d8, 0xc0143922a0})
        honnef.co/go/tools@v0.4.0/unused/unused.go:831 +0x156f
honnef.co/go/tools/unused.(*graph).namedType(0xc000eaf618, 0x131bb88?, {0x131f720?, 0xc013612dc8?})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1516 +0x458
honnef.co/go/tools/unused.(*graph).decl(0xc000eaf618, {0x131f360?, 0xc002a79240}, {0x0, 0x0})
        honnef.co/go/tools@v0.4.0/unused/unused.go:1099 +0xa72
honnef.co/go/tools/unused.(*graph).entry(0xc000eaf618)
        honnef.co/go/tools@v0.4.0/unused/unused.go:518 +0xc28
honnef.co/go/tools/unused.run(0xc01b0b4780)
        honnef.co/go/tools@v0.4.0/unused/unused.go:219 +0x245
github.com/golangci/golangci-lint/pkg/golinters.runUnused(0xc01b0b4780)
        github.com/golangci/golangci-lint/pkg/golinters/unused.go:61 +0x48
github.com/golangci/golangci-lint/pkg/golinters.NewUnused.func1(0xf82d00?)
        github.com/golangci/golangci-lint/pkg/golinters/unused.go:31 +0x2f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc001c486e0)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:188 +0x9df
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:106 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001a1e4b0, {0x10ccb49, 0x6}, 0xc001631f48)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc001522900?)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc001c486e0)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct 
INFO [runner] processing took 4.7µs with stages: max_same_issues: 967ns, nolint: 777ns, skip_dirs: 407ns, cgo: 376ns, autogenerated_exclude: 244ns, max_from_linter: 244ns, path_prettifier: 166ns, skip_files: 155ns, exclude-rules: 146ns, max_per_file_from_linter: 142ns, uniq_by_line: 139ns, identifier_marker: 138ns, filename_unadjuster: 137ns, path_prefixer: 137ns, exclude: 128ns, source_code: 127ns, sort_results: 77ns, diff: 66ns, path_shortener: 66ns, severity-rules: 61ns 
INFO [runner] linters took 15.370975738s with stages: goanalysis_metalinter: 15.37091864s 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "main" (isInitialPkg: true, needAnalyzeSource: true): internal error: unhandled case *types.Struct
 
INFO Memory: 156 samples, avg is 445.9MB, max is 607.4MB 
INFO Execution took 15.748046257s 

Code example or link to a public repository

// add your code 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