我有一個 Golang 專案,我使用的版本是 1.13。我的模塊托管在我的私人倉庫中。我的回購開始于:
module <Private-Repo>-service
go 1.13
還有一些來自 Github 的 Repos 和 go 包。我正在使用 Golang 的 vs 代碼包
谷歌團隊
我有我的環境:
GOROOT="/usr/local/go"
GOPATH="/home/{User}/go"
GOPRIVATE=<Private-Repo-URL>
我復制我的 Repo 的檔案夾在 /home/{User}/go/src/
但我無法解決這個問題,它說:
could not import github.com/golang/mock/gomock (cannot find package "github.com/golang/mock/gomock" in any of
/usr/local/go/src/github.com/golang/mock/gomock (from $GOROOT)
/home/{User}/go/src/github.com/golang/mock/gomock (from $GOPATH))compilerBrokenImport
所以我需要在 Visual Studio 代碼中修復這個問題。
uj5u.com熱心網友回復:
如果問題仍然存在,請先嘗試:
- 在命令列中(去獲取 github.com/golang/mock/gomock,在你專案的根檔案夾中,其中
go.mod/go.sum是) - 升級后,如果可能的話,去1.17。
一旦 go build 在命令列中作業,您可以切換回 VSCode,并確認它在那里也正常。
uj5u.com熱心網友回復:
而不是直接存盤你的內部代碼的$GOPATH,試圖將其存盤另一個目錄內即github.com/{github-username}/。
從:
/home/{User}/go/src/
到:
/home/{User}/go/src/github.com/{github-username}/
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/325958.html
上一篇:重新禁用大檔案的擴展
