gvt 依赖管理

在日常开发中,我们需要各种依赖库,gvt
1 安装

cd $GOPATH
go get github.com:FiloSottile/gvt
#将在gopath/bin/下生成 gvt 工具

2 使用gvt

#在$GOPATH/src 下创建项目  test
cd test
gvt fetch github.com/go-errors/errors
#自动创建 vendor文件夹并下载依赖
ls vendor
github.com  manifest

#生成manifest json文件
cat manifest
{
    "version": 0,
    "dependencies": [
        {
            "importpath": "github.com/go-errors/errors",
            "repository": "https://github.com/go-errors/errors",
            "vcs": "git",
            "revision": "d98b870cc4e05f1545532a80e9909be8216095b6",
            "branch": "master",
            "notests": true
        }
    ]
}

3 在manifest 文件中追加依赖dependencies中加入

#例如追加protobuf
    {
      "importpath": "github.com/golang/protobuf",
      "repository": "https://github.com/golang/protobuf",
      "vcs": "git",
      "revision": "b285ee9cfc6c881bb20c0d8dc73370ea9b9ec90f",
      "branch": "master",
      "notests": true
    }

4 更新依赖

gvt update --all

5 这样就可以使用gvt来管理go项目依赖了。

你可能感兴趣的:(gvt 依赖管理)