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 ingo.sum
. Pretty awesome 😃
解決方法:
-
使用低版本的go, 但更推薦第二種方法.
-
刪除自帶
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