go-tools
go-tools copied to clipboard
file in Go build cache being flagged
$ staticcheck -version
staticcheck 2021.1 (v0.2.0)
$ staticcheck -debug.version
staticcheck 2021.1 (v0.2.0)
Compiled with Go version: go1.16.4
Main module:
honnef.co/go/[email protected] (sum: h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=)
Dependencies:
github.com/BurntSushi/[email protected] (sum: h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=)
golang.org/x/[email protected] (sum: h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=)
golang.org/x/[email protected] (sum: h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ=)
golang.org/x/[email protected] (sum: h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8=)
golang.org/x/[email protected] (sum: h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=)
We have a package with
// Package foo does xyz.
//
// Deprected: foo bar baz.
package foo
Running go run honnef.co/go/tools/cmd/staticcheck ./... over our repo results in
../../../../Library/Caches/go-build/27/27e948b504ebf9b8801ef99c38e4fc3e9cc62114270ba835130b1731d2658508-d:13:2: package acme.corp/foo is deprecated: foo bar baz. (SA1019)
The build cache file is generated by go test and imports acme.corp/foo.
Can you show me the contents of the file in the cache? Or at least the beginning of it, up to and including the problematic import?
I am not sure if it's the same, but I'm seeing similar behavior (the file name is a cached file) but what's actually triggering it is a _test.go file with a different package name. Eg. if I have deprecated package foo and a _test.go file that uses the package foo_test that imports foo to test it, staticcheck treats this as if it's an import of the deprecated foo package. This seems wrong to me, because of course the tests import the deprecated package, the whole point is that they test that package until such a time as it gets removed. This may be a separate issue from the fact that it reports the name of the _test.go file as the cached version, though?
Those would be two separate issues, yes. But if it also triggers this issue then that's at least convenient.
Lacking any feedback from OP I am going to assume that this is the same bug as #1285. Closing.