Closed mirtchovski closed 5 years ago
also, there doesn't seem to be an import "bson"
anywhere in the vendor/ directory:
$ find vendor -type f -print0 | xargs -0 grep bson
vendor/gopkg.in/yaml.v2/yaml.go:// The code in this section was copied from mgo/bson.
the problem is that the go mod tool always tries to download, cache, and reference this repository, even though there appears to be no need for it. this is causing grief primarily because it requires specialized tools to download (bzr).
go mod vendor
prunes out tests of dependencies. go mod why
does not.
@mirtchovski, the need for specialized tools will be mitigated by public module proxies. (And note that if labix.org/v2/mgo/bson
isn't actually needed to resolve any direct imports in the packages you're building and testing, then you only need its go.mod
file.)
go mod why
seems to be giving you correct information: go mod why labix.org/v2/mgo
searches for a package dependency, not a module dependency. (For the latter, you would want go mod why -m labix.org/v2/mgo
.)
So it seems like this is, at best, a documentation issue. Did any particular document point you toward the use of go mod why
? If so, perhaps we can clarify it.
I believe I missed the -m from go mod why. With that it tells me exactly what I wanted. You can close this.
This has bitten me many times now, and I find it confusing. How do I know whether or not something in my go.mod file is a package or module? My primary use of go mod why
is to find out why go.mod contains a dependency; are there any other uses?
Whether or not my dependency is a package or module, is confusing to me (and probably others), and I would argue that the go mod why
command should return a result either way. If the tool finds that the main module does not depend on the supplied package it should check if it depends on a corresponding module instead, obviating the need for the -m flag. Be helpful to users; make the default use case easy.
@meling This issue is closed and is no longer tracked. If you want to propose a change or report a bug, please open a new issue.
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?
What did you expect to see?
At least some mention of the package "bson" anywhere in go mod's output.
What did you see instead?
Zero mention of the package "bson" anywhere in go mod's output.