-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: go mod vendor preserves go.mod and go.sum files unpredictably #42970
Comments
To clarify, you mean if the package at the root of the third-party module is used and vendored, right? |
This is probably feasible, but it may be misleading when vendoring a package for which there are multiple modules whose paths are prefixes in the build list. For example, suppose package I'm not sure what we do here for license files. I didn't actually know we copied them into the vendor directory when the root package of a module is not vendored. |
I assume that might be a requirement, since many licenses like GPL require distributing the license text when distributing the code. If we include go.mod/go.sum, which I think can be reasonable, that perhaps opens the door to other "special" top-level files like READMEs too, which pkgsite also treats in a special way. |
I think we should actually strip out Otherwise, if you |
If someone wants to obtain or inspect those go.mod files, I assume they can always inspect |
The general rule for The |
@mvdan, |
(And |
Just out of a meeting; catching up now
Correct, yes
You mean if
Yes, some licenses require that (and at least the
Tempted to say: "don't do that", but 🤷♂️ that said; I know use-cases where the vendor directory is used to build binaries, in which case (I think?) that may actually be the behavior someone is looking for?)
I do think the |
Yes.
I think this is a somewhat common use case. When we were talking about removing vendoring early on, we got feedback that a lot of people preferred vendoring because they could easily poke around the vendor to directory to view and modify their dependencies' code.
Could you expand on this a bit more? Generally I'm worried that adding |
The diffs of the In an offline situation, you can't edit dependency versions without a populated module cache anyway. (And if you do have a populated module cache, the relevant |
Change https://golang.org/cl/315410 mentions this issue: |
Thanks! |
Change https://golang.org/cl/335050 mentions this issue: |
…go version Updates golang/go#36876 Updates golang/go#42970 Updates golang/go#45965 Change-Id: I542e9ece986806f9b4a062f242387b1ca47f5814 Reviewed-on: https://go-review.googlesource.com/c/website/+/335050 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
…go version Updates golang/go#36876 Updates golang/go#42970 Updates golang/go#45965 Change-Id: I542e9ece986806f9b4a062f242387b1ca47f5814 Reviewed-on: https://go-review.googlesource.com/c/website/+/335050 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
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?
containerd recently switched to using go modules (with vendoring), and I noticed that
go.mod
for dependencies is only preserved if the main module is used, for example;https://github.com/containerd/containerd/tree/59a0667cff783b9e4e61ea2a138db220b4fbdca2/vendor/github.com/containerd/cgroups
However, a dependency for which only some packages are vendored, but not the main module,
go.mod
, andgo.sum
are omitted; for example: https://github.com/containerd/containerd/tree/59a0667cff783b9e4e61ea2a138db220b4fbdca2/vendor/github.com/opencontainers/runcWhat did you expect to see?
I expected both
go.mod
andgo.sum
to be preserved for any dependency, irregardless if the main module is consumed or not (similar to howLICENSE
andNOTICE
of the main module are preserved.What did you see instead?
I saw that
go.mod
andgo.sum
are only preserved if the main module is consumed.The text was updated successfully, but these errors were encountered: