Skip to content

go1.18 breaks govet nilness and unusedwrite #2668

Closed
@nvx

Description

@nvx

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

govet nilness and unusedwrite linters break with go1.18.

Uncommenting the disable lines in the example config provided fixes the issue. These should be disabled when go: 1.18 is specified in the config file like other problematic linters.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.45.0 built from 1f4c1ed9 on 2022-03-18T15:08:39Z

Configuration file

$ cat .golangci.yml
run:
  go: 1.18

linters:
  disable-all: true
  enable:
    - govet

linters-settings:
  govet:
    enable-all: true
#    disable:
#      - nilness
#      - unusedwrite

Go environment

$ go version
go version go1.18 windows/amd64

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ C:\\Users\\user\\go\\src\\example.com\\user\\foo C:\\Users\\user\\go\\src\\example.com\\~user C:\\Users\\user\\go\\src\\example.com C:\\Users\\user\\go\\src C:\\Users\\jc19324
3\\go C:\\Users\\user C:\\Users C:\\]"
level=info msg="[config_reader] Used config file .golangci.yaml"
level=info msg="[lintersdb] Active 1 linters: [govet]"
level=info msg="[loader] Go packages loading at mode 575 (deps|exports_file|name|types_sizes|compiled_files|files|imports) took 556.7883ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 0s"
level=info msg="[linters context/goanalysis] analyzers took 6.5542ms with top 10 stages: findcall: 1.7631ms, printf: 1.7266ms, ctrlflow: 1.1903ms, copylocks: 646.7µs, shadow: 572.8µs, reflectvaluecompare: 508.8µs, unreachable: 46.1µs, sigchanyzer: 46.1µs, bools: 17.
9µs, unusedresult: 17.9µs"
level=error msg="[runner] Panic: nilness: package \"foo\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA: goroutine 526 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x65\ngithub.com/gola
ngci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x155\npanic({0x12cf460, 0xc0004f44e0})\n\truntime/panic.go:838 +0x207\ngolang.org/x/tools/go/analysis/passe
s/nilness.run(0xc0004fac30)\n\tgolang.org/x/[email protected]/go/analysis/passes/nilness/nilness.go:64 +0xad\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0004d0bd0)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_
action.go:187 +0x9c4\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x1d\ngithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).Trac
kStage(0xc0002119f0, {0x13e777a, 0x7}, 0xc000653f48)\n\tgithub.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc000190d90?)\n\tgithub.com/golangci/golangci-lint/pkg/g
olinters/goanalysis/runner_action.go:104 +0x85\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0004d0bd0)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4\ncreated by githu
b.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb\n"
level=warning msg="[runner] Can't run linter govet: govet: nilness: package \"foo\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA"
level=info msg="[runner] processing took 0s with stages: identifier_marker: 0s, uniq_by_line: 0s, diff: 0s, max_same_issues: 0s, source_code: 0s, severity-rules: 0s, cgo: 0s, skip_files: 0s, path_prefixer: 0s, autogenerated_exclude: 0s, exclude: 0s, sort_results: 0s
, path_prettifier: 0s, skip_dirs: 0s, filename_unadjuster: 0s, max_per_file_from_linter: 0s, max_from_linter: 0s, path_shortener: 0s, exclude-rules: 0s, nolint: 0s"
level=info msg="[runner] linters took 6.1284ms with stages: govet: 5.5819ms"
level=error msg="Running error: 1 error occurred:\n\t* can't run linter govet: govet: nilness: package \"foo\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA\n\n"
level=info msg="Memory: 8 samples, avg is 53.1MB, max is 53.1MB"
level=info msg="Execution took 635.3789ms"

Code example or link to a public repository

package set
type Set[T comparable] map[T]struct{}

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions