我这里有一个刚起步的项目, 现在想要集成 govender .
介绍 govendor 的文章可以在网上搜索, 比如:https://www.jianshu.com/p/64890fe2d2c3, 我这里结合自己的项目写一下用法.
安装
go get -u github.com/kardianos/govendor
安装完后直接命令行中输入 govendor
, 若有输出则证明已安装成功
init
在项目目录下执行, 完毕后查看目录, 应该有了 vendor
目录
govendor init
列出本项目中在使用的信赖
(➜ microKnow git:(master) ✗
是我命令行常驻的头, 后面是我执行的命令)
➜ microKnow git:(master) ✗ govendor list
e github.com/astaxie/beego
e github.com/astaxie/beego/config
e github.com/astaxie/beego/context
e github.com/astaxie/beego/context/param
e github.com/astaxie/beego/grace
e github.com/astaxie/beego/logs
e github.com/astaxie/beego/session
e github.com/astaxie/beego/toolbox
e github.com/astaxie/beego/utils
e golang.org/x/crypto/acme
e golang.org/x/crypto/acme/autocert
e gopkg.in/yaml.v2
e github.com/shiena/ansicolor
pl github.com/RobinTsai/microKnow
l github.com/RobinTsai/microKnow/controllers
l github.com/RobinTsai/microKnow/routers
l github.com/RobinTsai/microKnow/tests
m github.com/smartystreets/goconvey/convey
其中 e, p, l, m
是 Status Type
, 可在 govendor
命令中查看
-
e
表示+external
表示在 gopath 中找到 -
p
表示+program
表示是主 package. -
l
表示+local
表示是自己项目中定义的 package -
m
表示+missing
表示在本地 (包括 govendor, gopath, goroot 下) 没有找到该包 -
s
表示+std
表示是标准库下的包 - 其他状态类型可通过
govendor
命令自行查看.
下面命令可以显示出所有信赖关系:
➜ microKnow git:(master) ✗ govendor list -v
e github.com/astaxie/beego
├── pl github.com/RobinTsai/microKnow
├── l github.com/RobinTsai/microKnow/controllers
├── l github.com/RobinTsai/microKnow/routers
└── l github.com/RobinTsai/microKnow/tests
...
比如上面表明 github.com/RobinTsai/microKnow
中用到了 github.com/astaxie/beego
包.
可以指定包来寻找信赖关系
➜ microKnow git:(master) ✗ govendor list -v fmt
s fmt
├── e github.com/astaxie/beego
├── e github.com/astaxie/beego/config
...
上面表明 fmt
在 github.com/astaxie/beego
中用到了.
安装缺失的包
比如将 github.com/astaxie/beego
安装到 vendor
中
fetch
命令会从远程仓库中拉取包, 而 add
会用 gopath
下的包添加入库
govendor fetch github.com/astaxie/beego
网友评论