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

最新文章

  1. Windbg Extension NetExt 使用指南 【3】 ---- 挖掘你想要的数据 Managed Heap
  2. 在phpmyadmin中执行sql语句出现的错误:Unknown storage engine &#39;InnoDB&#39;
  3. Uva 10167 - Birthday Cake 暴力枚举 随机
  4. CentOs Linux 分区建议
  5. SpringMVC10数据验证
  6. 加深理解UIView,UIResponder,UIController
  7. DocFX
  8. 5.VBS的一些约定,提高可读性
  9. 浅谈对ST表的一些理解
  10. Axios源码深度剖析 - 替代$.ajax,成为xhr的新霸主
  11. hbase概述和安装
  12. java过滤emoji表情
  13. Python 的xlutils模块
  14. Gmapping笔记
  15. [python] 3 、基于串口通信的嵌入式设备上位机自动测试程序框架(简陋框架)
  16. java 方法超时
  17. javascript:getElementsByName td name
  18. mysql中,创建包含json数据类型的表?创建json表时候的注意事项?查询json字段中某个key的值?
  19. [Visual Studio] SOA服务框架搭建
  20. Reference Type Casting

热门文章

  1. Python语言 介绍
  2. L2-3. 悄悄关注【STL+结构体排序】
  3. 空间划分的数据结构(网格/四叉树/八叉树/BSP树/k-d树/BVH/自定义划分)
  4. Java实验--关于课上找“水王”问题分析
  5. Understand the Business Domain
  6. C 标准库 - &lt;locale.h&gt;
  7. ios You app information could not be saved. Try again. If the problem persists, contact us
  8. C++11 并发指南四(&lt;future&gt; 详解一 std::promise 介绍)(转)
  9. LNMPA遇到504 Gateway time-out错误的解决方法
  10. hibernate5(10)注解映射[2]一对多单向关联