有没有一种方法可以更新 Go 包并忽略错误?

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

is there a way to update go packages and ignore errors?

问题

以下是翻译好的内容:

这是情景:

  • 在包myPackage中,我进行了一个破坏性的改变。别担心,它是私有的,没有人在意。
  • 在项目myProject中,我想使用新的myPackage版本。
  • myProject中运行go get -u ./...不会更新包,因为go会发现错误(由于破坏性的改变)。

我可以理解这是一个好主意,但在这种情况下,我希望go强制更新,打破一切,这样我就可以跟随编译器错误,直到我的代码最终准备好。

有没有办法实现这一点?

英文:

Here's the scenario:

  • in package myPackage I make a breaking change. No worries, it's private, nobody cares
  • in project myProject I would like to use the new myPackage version.
  • running go get -u ./... in myProject will not update the package, since go will find errors (due to the breaking changes).

I can see how this is a good idea, but in this very case I would like go to force the update, break everything, so I can follow the compiler errors until my code is finally ready.

Is there any way to achieve this ?

答案1

得分: 2

-d 标志会导致 go get 下载所请求的包,但不会构建它们。(从 Go 1.18 开始,-d 标志计划成为 go get 的默认行为,详情请参考 这里。)

go get -d -u ./... 应该会执行你想要的更新操作。

英文:

The -d flag causes go get to download the requested packages but not build them. (The -d flag is planned to be the default behavior of go get starting with Go 1.18.)

go get -d -u ./... should perform the update you intend.

huangapple
  • 本文由 发表于 2021年9月21日 15:36:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/69265065.html
匿名

发表评论

匿名网友

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

确定