Description
Creating this issue as a follow up to #26366 (and others).
go mod vendor
is documented as follows:
Vendor resets the main module's vendor directory to include all packages
needed to build and test all the main module's packages.
It does not include test code for vendored packages.
Much of the surprise in #26366 comes about because people are expecting "other" files to also be included in vendor
.
An alternative to the Go 1.5 vendor
is to instead "vendor" the module download cache. A proof of concept of this approach is presented here:
https://github.com/myitcv/go-modules-by-example/blob/master/012_modvendor/README.md
Hence I propose go mod modvendor
, which would be documented as follows:
Modvendor resets the main module's modvendor directory to include a
copy of the module download cache required for the main module and its
transitive dependencies.
Name and the documentation clearly not final.
Benefits (WIP)
- Eliminates any potential confusion around what is in/not in
vendor
- Easier to contribute patches/fixes to upstream module authors (via something like
gohack
), because the entire module is available - The modules included in
modvendor
are an exact copy of the original modules. This makes it easier to check their fidelity at any point in time, with either the source or some other reference (e.g. Athens) - Makes clear the source of modules, via the use of
GOPROXY=/path/to/modvendor
. No potential for confusion like "will themodvendor
of my dependencies be used?" - A single deliverable
- Fully reproducible and high fidelity builds (modules in general gives us this, so just re-emphasising the point)
- ...
Costs (WIP)
- The above steps are currently manual; tooling (the go tool?) can fix this
- Reviewing "vendored" dependencies is now more involved without further tooling. For example it's no longer possible to simply browse the source of a dependency via a GitHub PR when it is added. Again, tooling could help here. As could some central source of truth for trusted, reviewed modules (Athens? cc @bketelsen @arschles)
- ...
Related discussion
Somewhat related to discussion in #27227 (cc @rasky) where it is suggested the existence of vendor
should imply the -mod=vendor
flag. The same argument could be applied here, namely the existence of modvendor
implying the setting of GOPROXY=/path/to/modvendor
. This presupposes, however, that the idea of modvendor
makes sense in the first place.
Background discussion:
https://twitter.com/_myitcv/status/1038885458950934528
cc @bcmills