简体   繁体   中英

Upgrade Go dependency module to a new major version

How to update/upgrade Go dependency module to a new major version?

  • I tried go get -v -u github.com/gofiber/fiber but that only get it upgraded to v1.14.6 , not the v2.0.1 as seen on its git page.
  • I tried go get -v -u github.com/gofiber/fiber@v2.0.1 , but get the following errors:

go get github.com/gofiber/fiber@v2.0.1: github.com/gofiber/fiber@v2.0.1: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

  • I then tried go get -v -u github.com/gofiber/fiber@v2 , but get the following errors: go get github.com/gofiber/fiber@v2: no matching versions for query "v2"

I then did some research, some are not detailed enough and miss the important info:

Some are just too wordy, talking a bunch of broad topics and not specific on the updating Go dependency module to a new major version task:

So I'm thinking a concise and complete list of what things need to be done for updating Go dependency module to a new major version would be beneficial to the Go community as a whole.

Much simpler than I thought --

  • replace every import of github.com/gofiber/fiber with github.com/gofiber/fiber/v2
  • do go get -v ./...

That's it. Not sure if it is a complete list thought, but it works for my specific case.

The rest is just to fix whatever the API changes that the new major version requires.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM