Overall go modules works just like the docs say. But, in one case, a dependent lib's latest tag is v1.3.0 which go mod tidy finds. However I need v1.1.0. No matter what I do (hand edit go.mod, go get -u) 'go build' merely reverts the version right back to v1.3.0 which breaks the build. Indeed, the whole point of modules is setting the dependencies: so how? Go get should set it permanently but it doesn't stay set. Using go1.13.5
modules: how to force version of dependent lib
Asked Answered
No matter what I do (hand edit go.mod, go get -u) ...
After you modify the version of the dependency in the go.mod
file, then what you need to do is perform go mod tidy
command (from your explanation I assume you haven't done it).
Example:
# modify the dependency version on go.mod, then
go mod tidy
If you use vendoring then you also need to run the go mod vendor
command to update the downloaded dependencies inside vendor/
folder.
# modify the dependency version on go.mod, then
go mod tidy
go mod vendor
Why do you have
go mod vendor
there? –
Commorancy @Commorancy if the vendor folder is there, then dependencies inside will be updated –
Kayleigh
Sure, but it's not obvious whether OP uses vendoring (or more correctly: there are signs they don't) –
Commorancy
© 2022 - 2024 — McMap. All rights reserved.
go get the/[email protected]
? See Go Wiki: Modules: How to Upgrade and Downgrade Dependencies – Boreas