如此,用dep擷取私人庫

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

如此,用dep擷取私人庫

介紹

dep是一個依賴管理工具。它需要1.9或更新的Golang版本才能編譯

dep已經能夠在生產環節安全使用,但還在官方的實驗階段,也就是還不在go tool中。但我想是遲早的事 :=)

指南和參考資料,請參閱文檔

擷取私人庫

我們常用的git方式有兩種,第一種是通過ssh,第二種是https

本文中我們以gitlab.com為案例,建立一個private的私人倉庫

通過ssh方式

首先我們需要在本機上產生ssh-key,若沒有產生過可右拐傳送門

得到需要使用的ssh-key後,我們開啟我們的gitlab.com,複製粘貼入我們的Settings -> SSH Keys

添加成功後,我們直接在Gopkg.toml裡配置好我們的參數

[[constraint]]  branch = "master"  name = "gitlab.com/eddycjy/test"  source = "git@gitlab.com:EDDYCJY/test.git"

在拉取資源前,要注意假設你是第一次用該ssh-key拉取,需要先手動用git clone拉取一遍,同意ECDSA key fingerprint

$ git clone git@gitlab.com:EDDYCJY/test.gitCloning into 'test'...The authenticity of host 'gitlab.com (52.167.219.168)' can't be established.ECDSA key fingerprint is xxxxxxxxxxxxx.Are you sure you want to continue connecting (yes/no)? yes...

接下來,我們在項目下直接執行dep ensure就可以拉取下來了!

問題

  1. 假設你是第一次,又沒有執行上面那一步(ECDSA key fingerprint),會一直卡住
  2. 正確的反饋應當是執行完命令後沒有錯誤,但如果出現該錯誤提示,那說明該儲存倉庫沒有被納入dep中(例:gitee
$ dep ensureThe following issues were found in Gopkg.toml:unable to deduce repository and source type for "xxxx": unable to read metadata: go-import metadata not foundProjectRoot name validation failed

通過https方式

我們直接在Gopkg.toml裡配置好我們的參數

[[constraint]]  branch = "master"  name = "gitlab.com/eddycjy/test"  source = "https://{username}:{password}@gitlab.com"

主要是修改source的配置項,username填寫在gitlab的使用者名稱,password為密碼

最後回到項目下執行dep ensure拉取資源就可以了

最後

dep目前還是官方實驗階段,還可能存在變數

請務必以sf上的原文為準,如果dep新版本有變動,會隨著修改

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.