Go使用glide管理依賴庫
安裝
使用yum安裝
$ sudo yum install glide
離線包安裝
$ curl https://glide.sh/get | sh
或者
$ wget -c https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz$ tar zxvf glide-v0.12.3-linux-amd64.tar.gz$ mv ./linux-amd64/glide <PATH>
初始化工程
$ mkdir myapp$ cd myapp$ export GOPATH=`pwd`$ /opt/glide/bin/glide init
初始化工程後,會產生一個glide.yaml檔案,內容如下:
$ cat glide.yaml package: .import: []
安裝依賴庫
安裝指定的庫
$ glide get --all-dependencies -s -v github.com/go-redis/redis...$ cat glide.yaml package: .import:- package: github.com/go-redis/redis version: ^5.0.0$ cat glide.lock hash: b83ff10e7d57ded1279813a443c646c253c6313617d0a6ba5f0f7ca19bf561ddupdated: 2016-10-24T05:47:44.591801527-04:00imports:- name: github.com/go-redis/redis version: 6f8957c5b7dece15d1ea5f592ec88f46ee2deffatestImports: []
安裝指定版本的庫
$ glide get --all-dependencies -s -v github.com/go-redis/redis#5.0.0$ cat glide.yamlpackage: .import:- package: github.com/go-redis/redis version: 5.0.0$ cat glide.lock hash: 7f8ea571efa3eae755284b25ef53a3ad08d78d0f02ec69cdda179add23959d08updated: 2016-10-24T05:59:55.037552576-04:00imports:- name: github.com/go-redis/redis version: 80cf5d1652d5590c35edc6c2dc1aa354790e3010testImports: []
根據設定檔安裝庫
首先編輯 glide.yaml 檔案,內容如下:
package: .import:- package: github.com/go-redis/redis version: 5.0.0
然後使用下面的命令來安裝庫
$ glide install
安裝完成後設定檔如下:
$ cat glide.yamlpackage: .import:- package: github.com/go-redis/redis version: 5.0.0$ cat glide.lock hash: 7f8ea571efa3eae755284b25ef53a3ad08d78d0f02ec69cdda179add23959d08updated: 2016-10-24T05:59:55.037552576-04:00imports:- name: github.com/go-redis/redis version: 80cf5d1652d5590c35edc6c2dc1aa354790e3010testImports: []
轉載請以連結形式標明本文連結
本文連結:http://blog.csdn.net/kongxx/article/details/52914210