如何更新Go的依赖项

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

How to update Go dependencies

问题

go mod tidy命令会将包的依赖项添加到go.mod文件中。我们如何在不手动编辑go.mod文件的情况下自动更新它们呢?例如,如果我使用make命令,我想添加一个类似的命令,可以更新我的包/仓库的所有依赖项,然后使用最新版本的包依赖项编译代码。

英文:

the go mod tidy adds package dependencies to the go.mod file. How we can update them automatically without manually editing go.mod file, e.g. by removing some entries? For instance, if I use make I want to add a similar command that can update all dependencies of my package/repo and then compile the code with latest version of package dependencies.

答案1

得分: 5

为了更新所有的依赖项,你需要使用以下命令:

go get -u

然后运行 go mod tidy

go get -u 命令会更新所有的包及其依赖项,并修改 go.mod 文件。

英文:

In order to update all the dependencies you need to use:

go get -u

And then go mod tidy.

go get -u updates all packages and their dependencies, changing the go.mod.

huangapple
  • 本文由 发表于 2021年8月2日 05:03:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/68614340.html
匿名

发表评论

匿名网友

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

确定