安装
$ go get github.com/Masterminds/glide
$ go install github.com/Masterminds/glide
初始化项目并在当前项目下创建glide.yaml文件
glide create
glide init
更新解析下载包依赖
glide update
glide up
安装依赖包到当前项目的vendor目录下
glide install
获取单个包
glide get
--all-dependencies 会下载所有关联的依赖包
-s 删除所有版本控制,如.git
-v 删除嵌套的vendor
查看
glide name
glide list
glide help
glide --version
清理缓存,缓存位置$HOME/.glide/cache/src
glide cc
设置镜像,镜像映射文件 $HOME/.glide/mirrors.yaml
glide mirror set [original] [replacement]
glide mirror set [original] [replacement] --vcs [type]
移除镜像
glide mirror remove [original]
获取包的镜像列表
glide mirror list
二、报错
1、墙的问题
[WARN] Unable to checkout golang.org/x/sys/windows
[ERROR] Error looking for golang.org/x/sys/windows/svc: Cannot detect VCS
解决:
(1) 设置镜像后可查看$HOME/.glide/mirrors.yaml文件
glide mirror set https://golang.org/x/sys https://github.com/golang/sys --vcs git
(2) 当前glide.yml追加
echo "- package: golang.org/x/sys" >>glide.yaml
(3) glide install
2、win10使用glide exit status 1
[ERROR] Unable to export dependencies to vendor directory: Error
moving files: exit status 1. output: Access is denied. 0 dir(s) moved.
解决:
(1)修改glide
vim github.com/Masterminds/glide/path/winbug.go
function "func CustomRename(o, n string) error" replace the following line
//cmd := exec.Command("cmd.exe", "/c", "copy", o, n)
cmd := exec.Command("robocopy.exe", o, n, "/e")
(2)重新编译glide
go install github.com/Masterminds/glide
https://zhuanlan.zhihu.com/p/27994151