【问题标题】:How to make sure go build is using all dependencies from vendor directory如何确保 go build 使用来自供应商目录的所有依赖项
【发布时间】:2017-03-21 07:27:13
【问题描述】:

我使用了 godep 并在 vendor/ 目录中出售了我的所有依赖项。 Go build 也运行良好。但是,我如何确定我的所有依赖项都已售出?

有什么命令可以确定吗?

【问题讨论】:

  • 切换到一个新的、干净的、空的 GOPATH,git clone 并构建。很简单。
  • 是的。这是一种方式。我只是问是否有任何方法可以避免它,比如在go build 命令中传递一个标志。

标签: go dependencies vendor godeps


【解决方案1】:

我的 CI 服务(Travis 是我使用的)让我知道。因为如果 deps 不可用,我的测试构建将失败。

无论如何,您都应该使用 CI 服务,然后您就可以免费获得该好处。

【讨论】:

  • 我正在开发一个小项目,该项目部署在 Heroku 上,并通过 github 启用了自动部署。
【解决方案2】:

我使用govendor 来管理依赖项,它有一个status 选项。以下是 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.

具体来说,你会做govendor status 来检查是否缺少包。

如果您决定使用 govendor,您可以通过以下方式开始:

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

另外,您在评论中提到您部署到 Herky,这里有一些 documentation from them on govendor

【讨论】:

    猜你喜欢
    • 2016-11-22
    • 2019-08-28
    • 2019-05-04
    • 1970-01-01
    • 1970-01-01
    • 2013-09-03
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    相关资源
    最近更新 更多