golang govendor windos下的使用
2019-12-12 本文已影响0人
青果山圣斗士
为何使用govendor?
解决项目部署到各个平台的包依赖问题。
govendor提供一个包管理的能力,方便在任意环境下编译部署。
首先下载govendor包到本地
go get -u github.com/kardianos/govendor
到govendor目录下执行
go build
go instanll
此时在GOPATH路径下的bin目录中应该生成了govendor.exe文件
执行 govendor 会发现没有这个指令的话,是windos环境变量没有配置。


将GOPATH 路径添加到path中,保存关闭
将当前会话窗口关掉,重新打开就可以识别govendor指令了。

具体使用
进入项目根目录,执行govendor init 初始化vendor目录和json配置。
常用指令:
govendor add +e //在GOPATH中引用的包,但不在当前项目的依赖添加到项目vendor目录
govendor update +e //更新
govendor remove +u //移除没有使用的依赖