我有一個帶有 gomod 的 Go 程序,當我運行時go build .出現(xiàn)以下錯誤:go: github.com/sirupsen/logrus@v1.4.2 用于兩個不同的模塊路徑(github.com/Sirupsen/logrus 和 github.com/sirupsen/logrus)我的 go mod 看起來像require (github.com/Sirupsen/logrus v1.4.2 // indirectgithub.com/sirupsen/logrus v1.4.2…) 我添加了以下內(nèi)容,但沒有幫助,知道嗎?replace ( github.com/Sirupsen/logrus v1.4.2 => github.com/sirupsen/logrus v1.4.2)在我的項目代碼中,我僅使用import小寫的路徑github.com/sirupsen/logrus
2 回答

鳳凰求蠱
TA貢獻1825條經(jīng)驗 獲得超4個贊
嘗試刪除該//indirect行,然后運行
go mod tidy # prune any extraneous requirements + other stuff
go clean # remove object files and cached files
go get -v -u all # update everything related to the dependencies
go build # finger crossed!

慕村9548890
TA貢獻1884條經(jīng)驗 獲得超4個贊
github.com/sirupsen/logrus
是 v1.4.2 中 go.mod 文件中所示的正確模塊名稱 -?https://search.gocenter.io/github.com~2Fsirupsen~2Flogrus/info?version=v1.4.2
因此,如上所述,github.com/Sirupsen/logrus v1.4.2
從go.mod
文件中刪除 的引用并運行go mod tidy
.?此命令會將缺少的版本依賴項添加到您的go.mod
文件中。
- 2 回答
- 0 關(guān)注
- 184 瀏覽
添加回答
舉報
0/150
提交
取消