govendor依赖包管理

1.govendor简介

golang工程的依赖包经常使用go get命令来获取,例如:go get github.com/kardianos/govendor ,会将依赖包下载到GOPATH的路径下。

常用的依赖包管理工具有godepgovendor等,在Golang1.5之后,Go提供了 GO15VENDOREXPERIMENT环境变量(Go 1.6版本默认开启该环境变量),用于将go build时的应用路径搜索调整成为 当前项目目录/vendor 目录方式。通过这种形式,我们可以实现类似于 godep 方式的项目依赖管理。

 

2.govendor安装

#v1.0.9

wget http://blob.wae.haplat.net/golang/govendor-v1.0.9.linux-amd64.tar.gz

tar zxvf govendor-v1.0.9.linux-amd64.tar.gz

rm /usr/bin/govendor && mv govendor /usr/bin

 

3.governdor使用

初始化

#进入到项目目录

cd /path/to/your/project

 

#初始化vendor目录

govendor init

 

 

#将GOPATH中本工程使用到的依赖包自动移动到vendor目录中

#说明:如果本地GOPATH没有依赖包,先go get相应的依赖包

govendor add +external

或使用缩写: govendor add +e

 

新增/更新依赖包 github拉取

# Update a package to latest, given any prior version constraint

govendor fetch golang.org/x/net/context

 

 

#使用HTTP协议

govendor fetch -insecure [url]

 

# Specify a specific version or revision to fetch

govendor fetch golang.org/x/net/context@a4bbce9fcae005b22ae5443f6af064d80a6f5a55

govendor fetch golang.org/x/net/context@v1   # Get latest v1.*.* tag or branch.

govendor fetch golang.org/x/net/context@=v1  # Get the tag or branch named "v1".

 

更新/新增依赖包  本地GOPATH拷贝

# Update packages from $GOPATH.

govendor update golang.org/x/net/context

删除依赖包

govendor remove [pkg]

 

参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值