1:下载安装glide
go get github.com/Masterminds/glide
glide的源码以及exe文件在第一个gopath目录,如果不知道哪个是第一个gopath,echo一下
echo %GOPATH%
2:把glide.exe加入系统环境变量path目录
我建议直接把glide.exe拷贝到GO安装目录/bin
3:进入自己的go work工程
glide init//初始化包依赖配置
glide get github.com/streadway/amqp //我这里是安装rabbitmq,自行按需修改
4:Unable to export dependencies to vendor directory
在windows平台glide get的时候,总是提示如下错误:
D:\goopen\src>glide get github.com/streadway/amqp
[INFO] Preparing to install 1 package.
[INFO] Attempting to get package github.com/streadway/amqp
[INFO] --> Gathering release information for github.com/streadway/amqp
[INFO] --> Adding github.com/streadway/amqp to your configuration
[INFO] Downloading dependencies. Please wait...
[INFO] --> Fetching updates for github.com/streadway/amqp
[INFO] Resolving imports
[INFO] Downloading dependencies. Please wait...
[INFO] Exporting resolved dependencies...
[INFO] --> Exporting github.com/streadway/amqp
[INFO] Replacing existing vendor dependencies
[ERROR] Unable to export dependencies to vendor directory: Error moving files: e
xit status 1. output:
0
搜索了好久,才看到一个pr,发现原因,这个bug只在windows平台有,可能土豪们都是用的mac。
5:rebuild glide
按照这个pr修改glide源码,进入glide目录,go build,然后把重新生成的glide拷贝到go安装目录/bin
ok,well done。