我在 golang 中使用第三方包,我想將它們添加到我的 git 存儲庫中,當我鍵入命令時,git add .出現以下錯誤warning: adding embedded git repository: github.com/beorn7/perkshint: You've added another git repository inside your current repository.hint: Clones of the outer repository will not contain the contents ofhint: the embedded repository and will not know how to obtain it.hint: If you meant to add a submodule, use:hint: hint: git submodule add <url> github.com/beorn7/perkshint: hint: If you added this path by mistake, you can remove it from thehint: index with:hint: hint: git rm --cached github.com/beorn7/perkshint: 如何確保我正確地控制包的版本以及我是否以正確的方式控制第三方包的版本?這是我的項目結構Project/|src/ | github.com/ | packages/我的 GOPATH 也指向項目目錄
1 回答

慕運維8079593
TA貢獻1876條經驗 獲得超5個贊
據我了解,您不使用任何包管理器,而是將包導入 $GOPATH。我建議您使用包管理器,例如dep
構建vendor
包含所有依賴項的目錄。當您運行時,dep ensure
它將遍歷您的代碼并自動提取所有依賴項。
編輯:自 go1.11 以來,作為 @jubobs,您可以使用go mod
. 基本前提同上dep
。
- 1 回答
- 0 關注
- 191 瀏覽
添加回答
舉報
0/150
提交
取消