govendor
cd 到工程目录。
govendor init : 初始化
govendor fetch : 拉取包
go 1.6以后编译go代码会优先从vendor目录先寻找依赖包;
controllers\articleController.go:6:2: cannot find package "github.com/gin-gonic/gin" in any of:
E:\gocode\src\gin_demo\vendor\github.com\gin-gonic\gin (vendor tree)
C:\Go\src\github.com\gin-gonic\gin (from $GOROOT)
E:\gocode\src\github.com\gin-gonic\gin (from $GOPATH)
先从vendor下面找,再去GOROOT下面找,最后去GOPATH去找。
go vendor 是go 1.5 官方引入管理包依赖的方式,1.6正式引入 其基本思路是,将引用的外部包的源代码放在当前工程的vendor目录下面,go 1.6以后编译go代码会优先从vendor目录先寻找依赖包; 1.解决的问题:
将源码拷贝到当前工程的vendor目录下,这样打包当前的工程代码到任意机器的$GOPATH/src下都可以通过编译,避免项目代码外部依赖过多,迁移后,
需要多次go get 外包依赖包;而且通过go get 重新拉去的外部依赖包的版本可能和工程开发时使用的不一致,导致编译错误问题。 2.未解决的问题:
无法精确的引用外部包进行版本控制,不能指定引用某个特定版本的外部包;只是在开发时,将其拷贝过来,但是一旦外部包升级,vendor下的代码不会跟着升级,
而且vendor下面并没有元文件记录引用包的版本信息,这个引用外部包升级产生很大的问题,无法评估升级带来的风险; 3.解决go vendor未解决的问题 使用govendor ,其有如下好处:
https://github.com/kardianos/govendor
1>.可以平滑的将现有非vendor项目转换为vendor项目
govendor add inport_out_packagename
2>会生成一个元数据文件,记录项目工程依赖的外部包,以及其版本信息
vendor/vendor.json
3>提供命令查看整个工程的依赖关系
goverdor --list
goverdor --list -v project:
https://github.com/kardianos/govendor
Sub-commands
init Create the "vendor" folder and the "vendor.json" file. #创建一个vendor目录并生成个空的verdor.json文件
list List and filter existing dependencies and packages. #查看已经存在的依赖包
add Add packages from $GOPATH. #把$GOPATH中的包拷贝到vendor目录下
update Update packages from $GOPATH. #把$GOPATH中的包更新到vendor目录下
remove Remove packages from the vendor folder. #从vendor目录下移除外部依赖包
status Lists any packages missing, out-of-date, or modified locally. #查看缺失的或者本地修改的包
fetch Add new or update vendor folder packages from remote repository. #从远程代码库拉取依赖包到vendor目录
sync Pull packages into vendor folder from remote repository with revisions #一句本地vendor/verdor.json文件指定的包机器版本信息从远程资源库拉取资源
from 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. #等于go get 但是同步外部依赖包到vendor目录,而不是$GOPATH/src
license List discovered licenses for the given status or import paths.
shell Run a "shell" to make multiple sub-commands more efficient for large
projects.
go tool commands that are wrapped:
`+<status>` package selection may be used with them
fmt, build, install, clean, test, vet, generate, tool
Status
Packages can be specified by their "status".
+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 explicitely 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 packages
govendor的更多相关文章
- govendor 无法添加.h文件
例如:github.com\ethereum\go-ethereum\crypto\secp256k1 是一个CGO项目 通过govendor add +external只能引入secp256k1下的 ...
- Go 包依赖管理工具 —— govendor
govendor 是一个基于 vendor 机制实现的 Go 包依赖管理命令行工具.与原生 vendor 无侵入性融合,也支持从其他依赖管理工具迁移,可以很方便的实现同一个包在不同项目中不同版本.以及 ...
- Glide和Govendor安装和使用
两个都是Go的包管理工具,二选一 Glide参考:golang 依赖管理 /etc/profile #Go export GOROOT=/home/lintong/software/go export ...
- Golang包管理工具之govendor的使用
1. govendor简介 golang工程的依赖包经常使用go get命令来获取,例如:go get github.com/kardianos/govendor ,会将依赖包下载到GOPATH的路径 ...
- govendor使用
一,开发端 前提是有一个已经go get过依赖包,并编译成功的项目. $ go get -u github.com/kardianos/govendor $ cd project_dir $ gove ...
- 017-通过govendor管理依赖包
1:安装 go get -u github.com/kardianos/govendor 2:配置环境变量 需要把 $GOPATH/bin/ 加到 PATH 中 D:\my_workspace\go_ ...
- ARTS-S govendor
govendor init govendor add +external
- govendor用法
为什么使用govendor go语言的依赖管理最主要的是版本控制问题. govendor是Golang的依赖包管理工具,它的出现可以避免不同用户在clone同一个项目后从外部获取不同依赖库版本的问题. ...
- 拾遗:govendor(Golang 依赖库版本控制)
官方资料: https://github.com/kardianos/govendor https://github.com/kardianos/govendor/blob/master/doc/fa ...
随机推荐
- 2017 ACM-ICPC 北京区域赛记录
------------------------------------------------------------------------------ 出发日 拖着一个大箱子走是真的累. 下午三 ...
- Spring Cloud系列文,Feign整合Ribbon和Hysrix
在本博客之前的Spring Cloud系列里,我们讲述了Feign的基本用法,这里我们将讲述下Feign整合Ribbon实现负载均衡以及整合Hystrix实现断路保护效果的方式. 1 准备Eureka ...
- ubuntu网络、包管理、工作内容小结
中国地图 1.配置IP cat /etc/network/interfaces auto lo iface lo inet loopback # The loopback network interf ...
- bzoj 1835/luogu P2605 : [ZJOI2010]base 基站选址
题目描述 有N个村庄坐落在一条直线上,第i(i>1)个村庄距离第1个村庄的距离为Di.需要在这些村庄中建立不超过K个通讯基站,在第i个村庄建立基站的费用为Ci.如果在距离第i个村庄不超过Si的范 ...
- Neural Networks and Deep Learning学习笔记ch1 - 神经网络
近期開始看一些深度学习的资料.想学习一下深度学习的基础知识.找到了一个比較好的tutorial,Neural Networks and Deep Learning,认真看完了之后觉得收获还是非常多的. ...
- [Algorithms] Tree Data Structure in JavaScript
In a tree, nodes have a single parent node and may have many children nodes. They never have more th ...
- G 全然背包
<span style="color:#3333ff;">/* /* _________________________________________________ ...
- Optimizer统计信息管理介绍
1. 前言 在我们的日常维护中受理一些一直以来运行得非常好的系统,突然有一天用户反馈没有做不论什么操作,系统的某个功能模块或者是某个报表曾经仅仅须要几秒.但如今须要几分钟或更长的时间都没有返回结 ...
- UIView 的 autoresizingMask 属性 详解。
转载自:liubo0_0的专栏 链接网址:http://blog.csdn.net/liubo0_0/article/details/7085935 在 UIView 中有一个autoresizin ...
- at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:)
错误提示 错误原因 參考链接 错误提示: at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:) 在Andro ...