Go1.14版本vendor和gomodule沖突問題


Go1.14版本vendor和gomodule沖突問題

go1.14版本使用go mod tidy構建依賴時會出現問題(見鏈接), 這個問題在go1.12版本是不會出現的.

https://github.com/restic/rest-server/issues/102

這是由於1.14版本官方加入了校驗機制導致的, 解答:

Hey, thanks for the hint! I'm guessing this is Go 1.14, right?

They added verification code that makes sure the vendored dependencies are in good order. You could either build without vendoring or run go mod vendor again, which will refresh everything. We will probably remove the vendored libraries, but until this is done we need to refresh them and commit the result.

Please be aware that when you do that, the Go tooling verifies that the correct code is placed into vendor/ by using the cryptographic hashes in go.sum. Pretty awesome 😃

解決方法:

  1. 使用低版本的go, 但更推薦第二種方法.

  2. 刪除自帶vendor重建依賴

    項目文件夾下不能有vendor目錄!!!, 除非是go mod vendor生成的

    # 保證在dtagentplus目錄下
    # 1. 刪除vendor文件夾
    mv vendor ${GOPATH}
    # 2. 重新replace本地依賴, 指向${GOPATH}/vendor
    vim go.mod
    # 3. 重建依賴
    go mod tidy
    # 4. 生成vendor, 可做可不做
    go mod vendor
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM