通过”go install”命令如何更新二进制文件?

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

How to update the binary by go install?

问题

以前我可以通过以下方式安装Go二进制包:

go get -u github.com/some_user/some_project

现在它不再起作用了,经过一些搜索,我了解到了一个替代方法:

go install github.com/some_user/some_project@latest

到目前为止还好,但是现在我在主分支上推送了一些更改,我原本期望再次运行相同的go install命令来更新已安装的二进制文件,但它没有更新。我想知道在go install中,go get -u的等效命令是什么。

英文:

I used to be able to install a go binary package by:

go get -u github.com/some_user/some_project

Now it does work any more, and after some googling, I learned an alternative:

go install github.com/some_user/some_project@latest

So far so good, but now I pushed a change to the master branch, and I was expecting to run the same go install command again to update the binary file installed, but it didn't. I wonder what the equivalent of go get -u will be with go install.

答案1

得分: 5

实际上,这不是因为GitHub的延迟。GitHub是一个Git代码库,一旦你推送了更改,你的代码库就会立即更新。这是因为goproxy的原因。Goproxy是一个用于Go包的集中式存储库,它的存在是为了尽可能避免手动版本更新代码库和其他许多原因引起的问题,我不会深入介绍,请在这里阅读更多信息。goproxy不会实时索引每个代码库,所以你无法看到你的更改。实际上,你可以告诉Go不使用go代理,直接使用GitHub:

GOPROXY=direct go get -u github.com/some/package

这里的direct意味着直接使用GitHub,也可以是其他任何存储库。

英文:

Actually it's not because of github delay. Github is a git repository, once you push your changes, your code repository gets updated immediately. It's because of goproxy. Goproxy is a centralized repository for go packages, and that's there to avoid (as much as possible) some problems with manually version updating to the code repository and many other reasons, which I'm not going to get deep into, read more here. goproxy wont index every code repository in real time, so that's why you couldn't see your changes. Indeed, you can tell go to not to use the go proxy, and use the github directly:

GOPROXY=direct go get -u github.com/some/package

The direct here means to use the github here directly, it can be any other repository.

huangapple
  • 本文由 发表于 2022年8月1日 15:26:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/73190155.html
匿名

发表评论

匿名网友

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

确定