简体   繁体   English

如何使用与 src 路径不同的模块名称更新 go 依赖项?

[英]How to update a go dependency with different module name than src path?

  • The location: github.com/elastic/beats地点: github.com/elastic/beats
  • The mod file: github.com/elastic/beats/go.mod模组文件: github.com/elastic/beats/go.mod
  • The module name: github.com/elastic/beats/v7模块名称: github.com/elastic/beats/v7
  • The tag: v7.10.2标签: v7.10.2

What LoTR incantation of go get to I have to run to get a little dependency update action?我必须运行 go 的go get咒语才能获得一些依赖项更新操作?

This will update to latest minor.patch version of v7:这将更新到 v7 的最新 minor.patch 版本:

go get github.com/elastic/beats/v7

or if you want a specific version to update/downgrade to:或者如果您希望将特定版本更新/降级为:

go get github.com/elastic/beats/v7@v7.10.2

Adding the -u flag will additionally update the dependencies of github.com/elastic/beats/v7 :添加-u标志将额外更新github.com/elastic/beats/v7的依赖项:

go get -u github.com/elastic/beats/v7

The argument list passed to go get should generally be a list of package paths or patterns , not just a module path.传递给go get的参数列表通常应该是package 路径或模式的列表,而不仅仅是模块路径。

For example, you might invoke:例如,您可以调用:

go get -d github.com/elastic/beats/v7/libbeat/beat@latest

in order to obtain the latest version of package …/libbeat/beat and also download any transitive dependencies needed for that package.为了获得最新版本的 package …/libbeat/beat下载 package 所需的任何传递依赖项。

(You can pass just a module path, and that should also update the version of the dependency module overall, but it will not download source code or module checksums for transitive dependencies that may be needed in order to build the updated package. go get does not in general know which transitive dependencies will be relevant to the commands that you plan to invoke after it, and it does not do extra work to speculatively identify relevant dependencies.) (您可以只传递一个模块路径,这也应该整体更新依赖模块的版本,但它不会下载可能需要的传递依赖的源代码或模块校验和,以便构建更新的go get确实通常不知道哪些传递依赖关系与您计划在它之后调用的命令相关,并且它不会做额外的工作来推测性地识别相关依赖关系。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM