In go mod, what is the difference between go get ... and go get -u ... commands?
You would use -u to update the dependencies to their latest available minor and patch versions. So if your module is using package foo.com/bar, running go get -u foo.com/bar will update not only foo.com/bar to the latest MINOR.PATCH, but also its dependencies.
Go modules follows semver: MAJOR.MINOR.PATCH
Changes in MINOR and PATCH should never break users, so they are "safe" to automatically update. That said, the conservative approach (without -u) doesn't update them and is appropriate in some cases.
An interesting quote from the modules wiki:
A common mistake is thinking go get -u foo solely gets the latest version of foo. In actuality, the -u in go get -u foo or go get -u foo@latest means to also get the latest versions for all of the direct and indirect dependencies of foo. A common starting point when upgrading foo is instead to do go get foo or go get foo@latest without a -u (and after things are working, consider go get -u=patch foo, go get -u=patch, go get -u foo, or go get -u).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With