Skip to content

Govet and staticcheck report a warning and an error instead of the problem in code #1885

Closed
@spinzed

Description

@spinzed
  • 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

When there is an error that govet and/or staticcheck should pick up, a warning and an error are printed instead like this:

$ golangci-lint run --no-config --disable-all --enable=vet
WARN [runner] Can't run linter govet: assign: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]]
ERRO Running error: assign: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]]
$ golangci-lint run --no-config --disable-all --enable=staticcheck
WARN [runner] Can't run linter staticcheck: SA1011: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)] errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]] 
ERRO Running error: SA1011: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)] errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]]

Expected behavior: govet and staticcheck should report problems without any warnings or errors. Below can be seen govet and staticcheck outputs when run standalone:

$ go vet
vet: ./ui.go:43:5: ui.test undefined (type App has no field or method test)
$ staticcheck
ui.go:43:5: ui.test undefined (type App has no field or method test) (compile)

This bug is really similar to one that affected typecheck which was fixed in 1.39.0 via #1861

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.39.0 built from 9aea4aee on 2021-03-26T08:02:53Z
Config file

None.

Go environment
$ go version && go env
go version && go env
go version go1.16.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/spinzed/.cache/go-build"
GOENV="/home/spinzed/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/spinzed/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/spinzed/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"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build249909861=/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/spinzed/Workspaces/repos/litch /home/spinzed/Workspaces/repos /home/spinzed/Workspaces /home/spinzed /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|exports_file|files|imports|name|types_sizes) took 210.076578ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.462269ms 
INFO [linters context/goanalysis] analyzers took 6.051037066s with top 10 stages: buildir: 4.579349346s, inspect: 452.554377ms, ctrlflow: 203.376924ms, fact_purity: 183.119115ms, nilness: 176.445286ms, fact_deprecated: 173.204605ms, printf: 127.162529ms, SA5012: 86.796829ms, typedness: 68.487828ms, varcheck: 16.878µs 
WARN [runner] Can't run linter goanalysis_metalinter: S1021: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)] errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]] 
INFO [runner] processing took 8.388µs with stages: max_same_issues: 1.942µs, cgo: 791ns, nolint: 666ns, skip_dirs: 583ns, uniq_by_line: 566ns, max_from_linter: 550ns, path_prettifier: 396ns, filename_unadjuster: 308ns, skip_files: 287ns, autogenerated_exclude: 279ns, path_shortener: 276ns, identifier_marker: 275ns, diff: 269ns, source_code: 205ns, exclude-rules: 183ns, max_per_file_from_linter: 171ns, sort_results: 166ns, exclude: 159ns, path_prefixer: 159ns, severity-rules: 157ns 
INFO [runner] linters took 4.505678926s with stages: goanalysis_metalinter: 4.505571142s 
ERRO Running error: S1021: failed prerequisites: [errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)] errors in package: [/home/spinzed/Workspaces/repos/litch/ui.go:43:5: ui.test undefined (type App has no field or method test)]] 
INFO Memory: 49 samples, avg is 205.2MB, max is 340.9MB 
INFO Execution took 4.722547415s
Code example or link to a public repository
package main

import "fmt"

// This is an overly simplified way to reproduce this problem.

type App struct{}

func main() {
	ui := App{}
	fmt.Println(ui.test)
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions