[英]How to use Go dep with GitLab subgroups
我有一個 Go 項目,它需要來自私有 GitLab 存儲庫的一些依賴項,例如 git.mydomain.com/myteam/category/subcategory/project.git。 但我收到這個錯誤。
ensure Solve(): remote repository at https://git.mydomain.com/myteam/category.git does not exist or is inaccessible: : exit status 128
這個問題在GitLab 支持跟蹤器上進行了詳細討論。
TL; 博士; 它(故意) 因私人回購而損壞:
[你的小組] 是私人的嗎? 如果是這樣,這是預期的行為,我建議從#1337(評論 36293613)開始閱讀討論。 在這種情況下,我們決定以犧牲可用性為代價來最大限度地提高安全性/隱私性。 推薦的解決方法是專門將 .git 添加到您的 URL。
我找到的唯一解決方案是使用go get
對.netrc
的支持,它為dep
以及現代 Go 模塊解決了這個問題。
創建一個~/.netrc
文件:
machine gitlab.com login <your gitlab username> password <the token created in step 1>
稍微保護您的.netrc
文件:
chmod 600 ~/.netrc
利潤
這現在應該工作:
dep ensure -add gitlab.com/<company>/<subgroup>/<project>
如果您使用的是私有 GitLab 安裝,我相信您會在適用的情況下用適當的主機名替換gitlab.com
。
我認為最好的解決方案是使用像athens這樣的代理服務器。 您可以添加您的 Gitlab-Credentials 並將其用作代理服務器。 然后雅典將處理身份驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.