Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
spinzed opened this issue Apr 3, 2021 · 1 comment · Fixed by #1886
Closed
4 tasks done
Assignees
Labels
bug Something isn't working

Comments

@spinzed
Copy link

spinzed commented Apr 3, 2021

  • 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)
}
@spinzed spinzed added the bug Something isn't working label Apr 3, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 3, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@spinzed spinzed changed the title Govet and staticcheck report a warning and an error instead of reporting the problem in code Govet and staticcheck report a warning and an error instead of the problem in code Apr 3, 2021
@ldez ldez self-assigned this Apr 3, 2021
@ldez ldez closed this as completed in #1886 Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants