-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: wrong package version used to vet orphaned code (?) #45678
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
Comments
which version of thrift is actually used? just because output of or find the line in your
|
$ go list -mod=readonly -m github.com/apache/thrift
github.com/apache/thrift v0.13.0 Also, in case it wasn't clear, my module has no direct dependency on thrift. $ go mod why github.com/apache/thrift
# github.com/apache/thrift
(main module does not need package github.com/apache/thrift) |
right now everything reachable, including unused things, participates in version selection. #36460 seeks to solve that. try |
Ah, interesting, thanks. Following #36460. $ go mod graph | grep github.com/apache/thrift
contrib.go.opencensus.io/exporter/jaeger@v0.1.0 github.com/apache/thrift@v0.12.0
go.uber.org/cadence@v0.10.5 github.com/apache/thrift@v0.0.0-20161221203622-b2a4d4ae21c7
go.uber.org/yarpc@v1.49.1 github.com/apache/thrift@v0.13.0
go.opencensus.io@v0.19.2 github.com/apache/thrift@v0.12.0
go.opencensus.io@v0.20.1 github.com/apache/thrift@v0.12.0 |
So it is correctly selecting the highest version ( Closing as working as intended. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have a project that depends on code in go.uber.org/cadence at version v0.10.5. I ran
go vet
on my code and got impossible-seeming output. See "Speculation," below.What did you expect to see?
Nothing.
What did you see instead?
Speculation
This output seems wrong because the version of thrift that cadence v0.10.5 depends on does not include those
context.Context
parameters.Here is the go.mod line from cadence v0.10.5 specifying a version of thrift: link
Here is one call in cadence v0.10.5 that
go vet
erroneously claims is wrong: linkHere is the declaration in thrift, at the version requested by cadence, showing that the call is in fact OK: link
Later versions of thrift do add a
context.Context
parameter to those calls, e.g. link (but without assigning a new major version number, naughty naughty).However, the code that
go vet
complains about is orphaned. Nothing in the cadence module calls it. And since it's in aninternal
tree, nothing outside cadence can call it.It therefore seems as if
go vet
is using the version of thrift that my module would want (i.e., the latest version, if my module wanted thrift) and, perhaps because the code in question is orphaned, ignoring the version of thrift that cadence has asked for.Note, I reproduced this with clean Go mod and build caches and with various settings for
GOPROXY
.The text was updated successfully, but these errors were encountered: