为什么使用govendor

go语言的依赖管理最主要的是版本控制问题。
govendor是Golang的依赖包管理工具,它的出现可以避免不同用户在clone同一个项目后从外部获取不同依赖库版本的问题。
govendor会将项目需要的依赖包添加到项目的vendor目录下,并且该目录中vendor.json文件会保存添加的依赖包的路径等信息。
Golang项目中的go文件在查找依赖的顺序是,先在vendor中查找,vendor没找到然后在GOPATH中查找,都没找到最后在GOROOT中查找。
govendor只是用来管理项目的依赖包,如果GOPATH中本身没有项目的依赖包,则需要通过go get先下载到GOPATH中,再通过govendor add +external拷贝到vendor目录中。

基本用法

安装govendor:go get -u github.com/kardianos/govendor
如果需要使用vendor的项目原本没有vendor,那么需要在该项目的目录下创建vendor
govendor init
之后如果需要添加依赖包,可以通过以下两种方式添加
govendor fetch 依赖包路径
govendor add 依赖包路径

.gitignore的配置:

/vendor/*
!/vendor/vendor.json

根据vendor.json下载依赖:govendor sync

govendor用法例子:

cd path/to/project
govendor init
govendor fetch project_url_with_out_http
cat vendor/vendor.json

govendor常用命令

  • 增加包,搜add,会得到add和fetch这2个命令。
  • 更新包,搜update,会得到update和fetch这2个命令。
  • 删除包,搜remove,得到remove这个命令。
  • 查看已经依赖的包,搜list,得到list、status、license命令,而符合你的是list,并且知道了status能列出过期的包。
➜  project_name git:(develop) govendor --help
govendor (v1.0.9): record dependencies and copy into vendor folder-govendor-licenses    Show govendor's licenses.-version              Show govendor version-cpuprofile 'file'    Writes a CPU profile to 'file' for debugging.-memprofile 'file'    Writes a heap profile to 'file' for debugging.Sub-Commandsinit     Create the "vendor" folder and the "vendor.json" file.list     List and filter existing dependencies and packages.add      Add packages from $GOPATH.update   Update packages from $GOPATH.remove   Remove packages from the vendor folder.status   Lists any packages missing, out-of-date, or modified locally.fetch    Add new or update vendor folder packages from remote repository.sync     Pull packages into vendor folder from remote repository with revisionsfrom vendor.json file.migrate  Move packages from a legacy tool to the vendor folder with metadata.get      Like "go get" but copies dependencies into a "vendor" folder.license  List discovered licenses for the given status or import paths.shell    Run a "shell" to make multiple sub-commands more efficient for largeprojects.go tool commands that are wrapped:"+status" package selection may be used with themfmt, build, install, clean, test, vet, generate, toolStatus Types+local    (l) packages in your project+external (e) referenced packages in GOPATH but not in current project+vendor   (v) packages in the vendor folder+std      (s) packages in the standard library+excluded (x) external packages explicitly excluded from vendoring+unused   (u) packages in the vendor folder, but unused+missing  (m) referenced packages but not found+program  (p) package is a main package+outside  +external +missing+all      +all packagesStatus can be referenced by their initial letters.Package specifier<path>[::<origin>][{/...|/^}][@[<version-spec>]]Ignoring files with build tags, or excluding packages from being vendored:The "vendor.json" file contains a string field named "ignore".It may contain a space separated list of build tags to ignore whenlisting and copying files.This list may also contain package prefixes (containing a "/", possiblyas last character) to exclude when copying files in the vendor folder.If "foo/" appears in this field, then package "foo" and all its sub-packages("foo/bar", …) will be excluded (but package "bar/foo" will not).By default the init command adds the "test" tag to the ignore list.If using go1.5, ensure GO15VENDOREXPERIMENT=1 is set.
命令 功能
init 初始化 vendor 目录
list 列出所有的依赖包
add 添加包到 vendor 目录,如 govendor add +external 添加所有外部包
add PKG_PATH 添加指定的依赖包到 vendor 目录
update $GOPATH 更新依赖包到 vendor 目录
remove 从 vendor 管理中删除依赖
status 列出所有缺失、过期和修改过的包
fetch 添加或更新包到本地 vendor 目录
sync 本地存在 vendor.json 时候拉去依赖包,匹配所记录的版本
get 类似 go get 目录,拉取依赖包到 vendor 目录

转载于:https://www.cnblogs.com/weiyinfu/p/10982848.html

govendor用法相关推荐

  1. linux go vendor目录,Go 包依赖管理工具 —— govendor

    govendor 是一个基于 vendor 机制实现的 Go 包依赖管理命令行工具.与原生 vendor 无侵入性融合,也支持从其他依赖管理工具迁移,可以很方便的实现同一个包在不同项目中不同版本.以及 ...

  2. c语言中external,static关键字用法

    static用法: 在C中,static主要定义全局静态变量.定义局部静态变量.定义静态函数. 1.定义全局静态变量:在全局变量前面加上关键字static,该全局变量变成了全局静态变量.全局静态变量有 ...

  3. Pandas_transform的用法

    先来看一个实例问题. 如下销售数据中展现了三笔订单,每笔订单买了多种商品,求每种商品销售额占该笔订单总金额的比例.例如第一条数据的最终结果为:235.83 / (235.83+232.32+107.9 ...

  4. Python中yield和yield from的用法

    yield 后面接的是 future 对象 调用方 委托生成器 yield from 直接给出循环后的结果 yield from 委托者和子生成器直接通信 yield from 直接处理stopIte ...

  5. pytorch学习 中 torch.squeeze() 和torch.unsqueeze()的用法

    squeeze的用法主要就是对数据的维度进行压缩或者解压. 先看torch.squeeze() 这个函数主要对数据的维度进行压缩,去掉维数为1的的维度,比如是一行或者一列这种,一个一行三列(1,3)的 ...

  6. python yield 和 yield from用法总结

    #例1. 简单输出斐波那契數列前 N 个数 #缺点:该函数可复用性较差,因为 fab 函数返回 None,其他函数无法获得该函数生成的数列 #要提高 fab 函数的可复用性,最好不要直接打印出数列,而 ...

  7. tf.nn.embedding_lookup()的用法

    函数: tf.nn.embedding_lookup( params, ids, partition_strategy='mod', name=None, validate_indices=True, ...

  8. OpenMP用法大全

    OpenMP基本概念 OpenMP是一种用于共享内存并行系统的多线程程序设计方案,支持的编程语言包括C.C++和Fortran.OpenMP提供了对并行算法的高层抽象描述,特别适合在多核CPU机器上的 ...

  9. Dorado用法与示例

    Dorado用法与示例 dorado用后总结 一.dorado概念 dorado的产品全名是"dorado展现中间件".从产品形态上dorado由两部分组成,第一部分是一个具有AJ ...

最新文章

  1. Oracle 12c 安装(内附软件包)
  2. Button控件的基本使用(初识封装、减少代码冗余性、代码优化)
  3. mysql有三种事务模式_MySQL之事务与三大范式
  4. C程序员眼里的Python
  5. 旧android 4 平板,如今的安卓平板值不值得买:小米平板4入坑指南
  6. Mdebug:基于React开发的移动web调试工具
  7. DivCss 布局应用案例实践总结
  8. python中timeout什么意思_Python爬虫(五)timeout以及retrying的使用
  9. 在Vue中使用svg格式字体图标
  10. C语言学习(十)C语言中的小数
  11. 微信语音技术原理_微信语音电话是如何实现的?
  12. 成为高薪的AI人工智能工程师的条件
  13. SpringBoot服务监控之Actuate
  14. 机器视觉领域的牛人主页及代码
  15. 深度学习模型训练的结果及改进方法
  16. 【小沐学NLP】Python实现聊天机器人(Selenium、七嘴八舌)
  17. 以太网已连接(?)上不了网,或以太网已关闭
  18. OpenCV - 自动纠正图片的文字倾斜
  19. ASM核心API-方法
  20. 关于unity粒子系统renderer设为mesh(网格)模式后无法旋转的问题

热门文章

  1. python数据处理实战
  2. java总结第四次//常用类
  3. UVa 202 Repeating Decimals
  4. shell实战之日志脱敏
  5. WebHeaderCollection 类
  6. Subarray Sum
  7. [批处理]NetstatFilter快速查找端口被占用问题
  8. 使用Lucene检索文档中的关键字
  9. windowoPhone7.1 Socket编程-实现手机与电脑通信
  10. 今天算做正式开始SP开发吧,第一步当然是将down下来的资料好好地看一看,顺便也记下这些有用的地址...