Open carnott-snap opened 4 years ago
it is not needed for build, as evidenced by
go mod why
. As such, when Igo mod tidy
, it gets dropped
That is exactly what go mod tidy
is documented to do (https://tip.golang.org/cmd/go/#hdr-Add_missing_and_remove_unused_modules):
it removes unused modules that don't provide any relevant packages.
Could you provide some more detail as to why you want to upgrade a module that does not provide any imported packages?
That is exactly what
go mod tidy
is documented to do (https://tip.golang.org/cmd/go/#hdr-Add_missing_and_remove_unused_modules):
This is not just in tip; thanks for the pointer.
Could you provide some more detail as to why you want to upgrade a module that does not provide any imported packages?
go.sum
and go.mod
. It flagged my go.sum
, as it looks the same as if the module was actually being used for build.crypto
is a transitive dependency, it would be easy for another developer to introduce a dependency upon sub
without realising that they were bringing in the vulnerable version.
lib
depends on the vulnerable version, I would like a way to flag/upgrade it.It flagged my
go.sum
, as it looks the same as if the module was actually being used for build.
Ah, #33008 could be related. For modules that do not contribute imported packages, the go.sum
file is only supposed to contain a checksum for the go.mod
file (not the full source code), but a bug in go mod tidy
causes it to also retain a checksum for the source code if present.
Since
crypto
is a transitive dependency, it would be easy for another developer to introduce a dependency uponsub
without realising that they were bringing in the vulnerable version.
That's true, but we should probably provide some means to flag those regardless of how they are introduced. (That's #24031.)
since we know
lib
depends on the vulnerable version, I would like a way to flag/upgrade it.
Note that if you really want to, you can introduce a dummy import of some package in order to convince go mod tidy
to keep it. (See http://golang.org/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module.)
Since we have issues filed for the other two parts, let's focus this one on the third: you have a reason to want to retain an otherwise-unused requirement, and we have a mechanism for that (a dummy import), so we should probably make the documentation for that mechanism more discoverable.
Is having a hugo module require
but not used in any .go
file (because I'm just pulling in content), a valid use case here? I can get it to work but I have to live with the "is not used in this module" warnings in vscode problems tab.
Hugo's use of modules isn't supported by the Go project — we're focused on the use-case of building and running Go binaries using go build
, go test
, and the like.
(We're not actively trying to break it either, but you'll need to take up any Hugo-specific issues with the Hugo maintainers.)
@bcmills fair enough. Thanks :)
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?
In light of the recent
golang.org/x/crypto
fix, I tried to enforce that my module usev0.0.0-20200220183623-bac4c82f6975
:golang.org/x/crypto
is listed in mygo.sum
because a module I depend upon uses it:It is assumed that I am not in control of the
lib
module:However it is not needed for build, as evidenced by
go mod why
. As such, when Igo mod tidy
, it gets dropped:What did you expect to see?
What did you see instead?