dtdsbakn210537 2016-06-21 06:03
浏览 46

golang + Godeps:添加新的依赖项覆盖G​​odeps.json文件

I'm using Godeps to save my dependencies with my go project.

For now my Godeps.json file looks like this:

{
    "ImportPath": "github.com/some/repo",
    "GoVersion": "go1.6",
    "GodepVersion": "v74",
    "Packages": [
        "gopkg.in/mgo.v2",
        "github.com/sendgrid/sendgrid-go",
        "gopkg.in/olivere/elastic.v3"
    ],
    "Deps": [
        {
            "ImportPath": "github.com/sendgrid/sendgrid-go",
            "Comment": "v2.0.0-22-g6ea8b2b",
            "Rev": "6ea8b2b2d54b2e54efcf8668867289a1838d96fd"
        },
        {
            "ImportPath": "github.com/sendgrid/smtpapi-go",
            "Comment": "v0.4.0-7-gb88787c",
            "Rev": "b88787cc8801ef961d7daef0bcb79ae3f50bfd52"
        },
        {
            "ImportPath": "gopkg.in/check.v1",
            "Rev": "4f90aeace3a26ad7021961c297b22c42160c7b25"
        },
        {
            "ImportPath": "gopkg.in/mgo.v2",
            "Comment": "r2016.02.04-1-gb6e2fa3",
            "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da"
        },
        {
            "ImportPath": "gopkg.in/mgo.v2/bson",
            "Comment": "r2016.02.04-1-gb6e2fa3",
            "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da"
        },
        {
            "ImportPath": "gopkg.in/mgo.v2/internal/sasl",
            "Comment": "r2016.02.04-1-gb6e2fa3",
            "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da"
        },
        {
            "ImportPath": "gopkg.in/mgo.v2/internal/scram",
            "Comment": "r2016.02.04-1-gb6e2fa3",
            "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da"
        },
        {
            "ImportPath": "gopkg.in/olivere/elastic.v3",
            "Comment": "v3.0.40",
            "Rev": "7a92d18eaf7a9f95d603e70970fb5adcd4dc62f1"
        },
        {
            "ImportPath": "gopkg.in/olivere/elastic.v3/backoff",
            "Comment": "v3.0.40",
            "Rev": "7a92d18eaf7a9f95d603e70970fb5adcd4dc62f1"
        },
        {
            "ImportPath": "gopkg.in/olivere/elastic.v3/uritemplates",
            "Comment": "v3.0.40",
            "Rev": "7a92d18eaf7a9f95d603e70970fb5adcd4dc62f1"
        }
    ]
}

If I want to install a new dependency using go get:

go get "github.com/robfig/cron"

This will override my Godeps.json file and it will store only the latest package I have installed, and further more It will delete the packages from my vendor folder.

How can I add this dependency instead of replace it?

  • 写回答

1条回答 默认 最新

  • drflkphi675447 2016-06-22 05:21
    关注

    If you do not run godeps save then the new dependency will not be saved in your Godeps.json. It's hard to imagine why you would want two version of the same library though, but if you really want to do it, then during deployment of your project, first do godep restore and then install your dependency as go get "github.com/robfig/cron".This will then prevent a replacement

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决