-
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
proposal: cmd/go: 'go get', 'go mod tidy' should update the vendor directory when present #45161
Comments
FWIW, I think the major behavior change that impacts this since #29058 is #42466. My main concern was that, because |
I'm a bit worried about that behavior. In my experience, users often invoke |
|
@oiooj, |
If user uses But if it automatically updates vendor, it‘s not easy for users to notice the change, even the mode they used.
If the user manually executes |
@oiooj To clarify, the If the
... So the current user experience is that a developer runs If they change |
This is basically the same issue as #29058, but the default behavior has changed, so it may be worth reopening the discussion.
Since 1.14, the go command may use the vendor directory by default (without the
-mod=vendor
flag) if thego
version ingo.mod
is 1.14 or higher andvendor/modules.txt
is present. The go command reports an error ifgo.mod
andvendor/modules.txt
are out of sync.Two commands primarily change
go.mod
:go mod tidy
andgo get
. When these commands make changes, they break vendor builds untilgo mod vendor
is run again.We've avoided rebuilding the vendor directory implicitly, since the go command currently deletes the entire folder, loads the import graph, and recreates it from scratch. That may cause developers to lose local changes (like a patch being prepared for a dependency).
I propose some new behavior:
vendor
. That probably means comparing the contents of each package directory to the corresponding directory in the module cache. That would help us implement cmd/go: allow verifying vendored code #27348.go get
would add or update packages in the vendor directory automatically if it's present. Only packages needed to build the packages named on the command line would be affected.go mod tidy
would implicitly rebuild the vendor directory.go mod vendor
would be a no-op aftergo mod tidy
.git checkout
orrm -rf vendor
first.go build
and other commands.-mod=readonly
and-mod=mod
would continue to ignore the vendor directory.cc @bcmills @FiloSottile @matloob
The text was updated successfully, but these errors were encountered: