govendor依赖包管理

链客区块链技术问答社区 · · 3158 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

    想知道更多关于区块链技术知识,请百度【链客区块链技术问答社区】

    链客,有问必答!

govendor依赖包管理1111

1.govendor简介

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

常用的依赖包管理工具有godep,govendor等,在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]


有疑问加站长微信联系(非本文作者)

本文来自:简书

感谢作者:链客区块链技术问答社区

查看原文:govendor依赖包管理

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

3158 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传