最近在跑一個項目clone 完成代碼之后需要進行構建,發現了如下問題
<wiz_code_mirror>
verifying gopkg.in/src-d/go-git.v4@v4.13.1/go.mod: checksum mismatch
downloaded: h1:G7mAYYxgmS0lVkHyy2hEOLQCFB0DlQFTMLWggykrydY=
go.sum: h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
然后搜索了下,一般的解決方法如下:
go clean -modcache
然后介紹方法是同時刪除go.sum的,實際上直接刪除go.sum 會有安全的問題,這種一般出現在國內
大家使用proxy的情況,推薦的方法是比較下,因為這個提示是為了安全,大家應該比較下,如下是
一個參考的比較方法
curl -s https://goproxy.cn/gopkg.in/src-d/go-git.v4/@v/v4.13.1.mod | sha256sum && \
curl -s https://goproxy.io/gopkg.in/src-d/go-git.v4/@v/v4.13.1.mod | sha256sum && \
curl -s https://goproxy.baidu.com/gopkg.in/src-d/go-git.v4/@v/v4.13.1.mod | sha256sum && \
curl -s https://mirrors.aliyun.com/goproxy/gopkg.in/src-d/go-git.v4/@v/v4.13.1.mod | sha256sum
比較完成之后推薦選擇一樣的proxy,重新配置下,這樣相對會安全點
參考資料
https://maiyang.me/post/2019-01-23-go-mod-tidy-occure-verify-checksum-mismatch/
https://github.com/goproxy/goproxy.cn/issues/46
https://github.com/golang/go/issues/29278