My go package version is v1.0.7 and now I want to upgrade it to v2.0.0. I create a new tag with it bug when I use go get CODEPATH
it still use version v1.0.7. The go.mod should like require CODEPATH v2.0.0+incompatible
but I want to know what command will do this?
The document Modules says that add /v2 to module path but didn't tell how to upgrade client's go.mod.
I tried myself and it worked.
/v2
to your go.mod's module line module github.com/mnhkahn/aaa/v2
;import "github.com/mnhkahn/aaa/v2/config"
;go get github.com/mnhkahn/aaa/v2
;go mod tidy
;The answer from Bryce looks good if you are doing this manually.
If you are interested in an automated approach (for example, perhaps you have many files you would need to visit), a good automated solution is https://github.com/marwan-at-work/mod, which can automatically add, remove, or change the required /vN
in your *.go
code and your go.mod
. See this answer for more details.
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