How to make sure go build is using all dependencies from vendor directory

huangapple go评论99阅读模式
英文:

How to make sure go build is using all dependencies from vendor directory

问题

你好!根据你的描述,你已经使用godep并将所有的依赖项放在了vendor/目录中,Go build也正常工作。但是你想知道如何确保所有的依赖项都已经被vendored了。

在Go语言中,可以使用以下命令来确保所有的依赖项都已经被vendored:

go mod vendor

这个命令会将所有的依赖项复制到vendor/目录中,如果已经存在,则会进行更新。这样你就可以确保所有的依赖项都已经被vendored了。

希望对你有帮助!如果你还有其他问题,请随时提问。

英文:

I have used godep and vendored all my dependencies in vendor/ directory. Go build is working fine as well. However how can I be sure that all my dependencies are vendored?

Is there any command that can make sure of that?

答案1

得分: 1

我的 CI 服务(我使用的是 Travis)会通知我。因为如果依赖项不可用,我的测试构建将失败。

无论如何,你应该使用一个 CI 服务,这样你就可以免费获得这个好处。

英文:

My CI service (Travis is the one I use) lets me know. Because my test build will fail if the deps aren't available.

You should be using a CI service anyway, and then you get that benefit for free.

答案2

得分: 0

我使用govendor来管理依赖项,它有一个status选项。以下是一些使用govendor的命令:

init     创建“vendor”文件夹和“vendor.json”文件。
list     列出和筛选现有的依赖项和包。
add      从$GOPATH添加包。
update   从$GOPATH更新包。
remove   从vendor文件夹中删除包。
status   列出任何缺失的、过时的或本地修改的包。
fetch    从远程仓库添加新的或更新的vendor文件夹包。
sync     从vendor.json文件中使用修订版本将包拉入vendor文件夹。
migrate  将包从旧工具迁移到带有元数据的vendor文件夹。

具体来说,你可以使用govendor status来检查是否有缺失的包。

如果你决定使用govendor,可以按照以下步骤开始:

  • go get github.com/kardianos/govendor
  • govendor migrate(将从godeps迁移到govendor)

另外,你在评论中提到你要部署到Heroku,这里有一些关于govendor的Heroku文档

英文:

I use govendor to manage the dependencies, which has a status option. Here's some of the commands with govendor:

init     Create the "vendor" folder and the "vendor.json" file.
list     List and filter existing dependencies and packages.
add      Add packages from $GOPATH.
update   Update packages from $GOPATH.
remove   Remove packages from the vendor folder.
status   Lists any packages missing, out-of-date, or modified locally.
fetch    Add new or update vendor folder packages from remote repository.
sync     Pull packages into vendor folder from remote repository with revisions
             from vendor.json file.
migrate  Move packages from a legacy tool to the vendor folder with metadata.

Specifically, you'd do govendor status to check if there are missing packages.

If you decide to use govendor, you can get started by doing:

  • go get github.com/kardianos/govendor
  • govendor migrate (which will migrate from godeps to govendor)

Also, you mentioned in a comment that your deploying to Heroky, here's some documentation from them on govendor

huangapple
  • 本文由 发表于 2017年3月21日 15:27:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/42920729.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定