1. 程式人生 > 其它 >附1 go get 私有倉庫 常見錯誤彙總

附1 go get 私有倉庫 常見錯誤彙總

技術標籤:pythonjavalinuxgitgo

本系列文章均為學習過程中記錄的筆記,歡迎和我一起來學習Go語言。

全文使用環境如下:

  • Go語言版本:1.14
  • 作業系統:deepin
  • 使用工具:Goland開發工具

我在日常編寫專案時總是喜歡使用自己的公共工具元件,go語言1.11版本以後增加了mod功能,這就可以將自己的公共元件直接從倉庫裡面拉取下來了,但是拉取的過程註定是存在天坑的,以下就是我在使用該功能時彙總的一些常見錯誤和解決方案,希望能給大家帶來一些幫助。

執行go get gitee.com/xxx/xxxxxx.git常見錯誤彙總

錯誤1

status 128:
        fatal: unable to connect to gitee.com:
        gitee.com[0: 212.64.62.174]: errno=No such file or directory
造成原因:

需要用https才能讀到資料

解決方案:

執行如下命令

git config --global url."[email protected]:".insteadOf "https://gitee.com/"

或在git的~/.gitconfig檔案中增加配置

[url "[email protected]:"]
    insteadOf = https://gitee.com/

錯誤2

go get gitee.com/xxx/xxxxxx.git: module gitee.com/xxx/xxxxxx.git: reading https://mirrors.aliyun.com/goproxy/gitee.com/xxx/xxxxxx.git/@v/list: 504 Gateway Timeout
造成原因:

使用了預設定的GOPROXY引數

解決方案:

go版本1.14及以後,根據自己的地址修改下面的命令並執行。授權特定地址不再使用GOPROXY和CHECKSUM等邏輯

set GOPRIVATE=gitee.com/xxxx,gitee.com/demo,*.gitee.com

錯誤3

Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://gitee.com/xxx/xxxxxx.git
Permission denied, user: 'lz239'
fatal: Could not read from remote repository.
造成原因:

當前git賬號無許可權

解決方案

修改~/.gitconfig檔案中的

[user]
    name = 使用者名稱
    email = 賬號郵箱
本文宣告:

知識共享許可協議
本作品由 cn華少 採用 知識共享署名-非商業性使用 4.0 國際許可協議 進行許可。

文章中凡是涉及的程式碼均在Gitee與GitHub上了,有需要的可以通過下面的地址下載。[圖片上傳失敗...(image-4b69d8-1592640396721)]

[圖片上傳失敗...(image-849061-1592640396721)]