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
新版本有变更,会随着修改