dep
是一個依賴管理工具。它須要1.9或更新的Golang
版本才能編譯git
dep
已經可以在生產環節安全使用,但還在官方的試驗階段,也就是還不在go tool
中。但我想是早晚的事 :=)github
指南和參考資料,請參閱文檔golang
咱們經常使用的git
方式有兩種,第一種是經過ssh
,第二種是https
segmentfault
本文中咱們以gitlab.com
爲案例,建立一個private
的私有倉庫安全
ssh
方式首先咱們須要在本機上生成ssh-key
,若沒有生成過可右拐傳送門ssh
獲得須要使用的ssh-key
後,咱們打開咱們的gitlab.com
,複製粘貼入咱們的Settings
-> SSH Keys
中工具
添加成功後,咱們直接在Gopkg.toml
裏配置好咱們的參數gitlab
[[constraint]] branch = "master" name = "gitlab.com/eddycjy/test" source = "git@gitlab.com:EDDYCJY/test.git"
在拉取資源前,要注意假設你是第一次用該ssh-key
拉取,須要先手動用git clone
拉取一遍,贊成ECDSA key fingerprint
:spa
$ git clone git@gitlab.com:EDDYCJY/test.git Cloning 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
就能夠拉取下來了!code
ECDSA key fingerprint
),會一直卡住dep
中(例:gitee
)$ dep ensure The following issues were found in Gopkg.toml: unable to deduce repository and source type for "xxxx": unable to read metadata: go-import metadata not found ProjectRoot 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
新版本有變更,會隨着修改