How do I migrate from Dep to Go Modules

前端 未结 3 2063
日久生厌
日久生厌 2020-12-24 06:17

I\'m currently using Dep and would like to start using Go modules.

How do I migrate?

3条回答
  •  悲&欢浪女
    2020-12-24 06:45

    Another way to upgrade to modules.

    • Remove the Gopkg.toml and Gopkg.lock

      rm Gopkg.*

    • Initialise the Go modules

      GO111MODULE=on go mod init

    • Run go mod tidy to pull all the indirect modules and remove unused modules

      GO111MODULE=on go mod tidy

    • Run build to ensure everything works fine

      go build

    Tip in case you face few modules not found then manually update the modules tag in go.mod file.

提交回复
热议问题