gpt4 book ai didi

golang + Godeps : Adding new dependency override Godeps. json文件

转载 作者:数据小太阳 更新时间:2023-10-29 03:27:03 24 4
gpt4 key购买 nike

我正在使用 Godeps 将我的依赖项保存到我的 go 项目中。

现在我的 Godeps.json 文件如下所示:

{
"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"
}
]
}

如果我想使用 go get 安装一个新的依赖:

去获取“github.com/robfig/cron”

这将覆盖我的 Godeps.json 文件,它只会存储我安装的最新包,而且还会从我的 vendor 文件夹中删除包。

如何添加而不是替换此依赖项?

最佳答案

如果您不运行 godeps save,那么新的依赖项将不会保存在您的 Godeps.json 中。很难想象为什么你会想要同一个库的两个版本,但如果你真的想这样做,那么在你的项目部署期间,首先执行 godep restore 然后安装你的依赖项 go get "github.com/robfig/cron"。这将防止替换

关于golang + Godeps : Adding new dependency override Godeps. json文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37936663/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com