Closed jianzhangbjz closed 3 years ago
Your title says all
but your examples show ./...
, which one is it?
Note ./...
matches the packages in the current module, so updating the current module is a noop. I think you want the -u
flag?
I also tried the go get -d all
, but it doesn't work either. I want to update the dependency info in the go.mod
. You know, some dependency packages' version are old, I want to update them together.
Seems like the go get -d all
updates the dependency, but it doesn't write the updated info to the go.mod
.
can you provide the entire output of go get -d all
?
I also tried the go get -d all, but it doesn't work either.
The most likely explanation for this behavior is that nothing in the module k8s.io/api
is in the package pattern all
.
(That would be the case if you have a transitive dependency on k8s.io/api
from some other module but don't actually use the parts of that other module that need the K8s API.)
Can you attach the output of both go get -d all
and go list all
?
Thanks for your analysis! List the related logs below:
As you can see above, there is no updates in the go.mod
, but some packages do need be updates, such as, k8s.io/api
, as follows,
[cloud-user@preserve-olm-env openshift-tests-private]$ go get -d k8s.io/api
go get: upgraded k8s.io/api v0.17.1 => v0.21.2
[cloud-user@preserve-olm-env openshift-tests-private]$ git status
On branch README
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: go.mod
no changes added to commit (use "git add" and/or "git commit -a")
Ignore the vendor
folder, as follows:
This looks to be working as intended. The lines like the one below indicate there was a problem with upgrading everything to their latest versions, usually because of breaking changes somewhere. In that case, go
won't do a partial upgrade into some inconsistent/unbuildable state.
go get all: module ... found but does not contain package ...
You'll have to do your upgrades more carefully to handle the changes than just "all"
Thanks! Yes, I understand there are upgrading problems in some denpendency pakcages. But, some not. The go get -d all
should update the go.mod
info for those succeed upgraaded packages.
Thanks for posting this output. It seems like this is working as intended though. @bcmills let me know if I'm wrong though.
go get -d all
instructs the go command to upgrade each package currently in all
(that is, packages in the main module and their transitive imports) to their latest versions. In this case, some packages, mostly internal packages, are not available at all at later versions.
go get -d -u ./...
is probably a better fit for this use case. That also upgrades packages transitively imported from the main module, but it's not a problem if a package disappears from all
during the upgrade process.
The go command won't write go.mod if there are errors. As @seankhliao said, there's risk of leaving go.mod in an inconsistent state if it did that. You can either upgrade individual packages or modules with separate go get -d
commands, or you can arguments like example.com/mod@v1.2.3
to keep the current versions of module's you're using (this will only work with -u
).
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I want to update all of the dependenciesies that in the
go.mod
, so I ran thego get -d ./...
. But, there are no any updates in thego.mod
file.But, when I specify a dependency package,
go get -d
works. As you can see, thego.mod
file was updated.What did you expect to see?
I hope to update all of the dependencies for the
go.mod
by using thego get -d ./...
What did you see instead?