go 1.5 : Is "go install" behaviour changed? Removing stale executables?

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

go 1.5 : Is "go install" behaviour changed? Removing stale executables?

问题

在Go 1.4.2之前,当我在运行go build之后运行go install时,我可以在当前文件夹中找到二进制文件。因此,以下Linux命令可以正常工作:

$ go build && go install && ./executable

但是在安装了Go 1.5之后,当我运行相同的命令时,我得到以下错误信息:

-bash: ./executable: 没有那个文件或目录

我检查了一下,发现没有可执行文件可以找到。Go 1.5中的go install行为是否发生了变化?

英文:

Till Go 1.4.2 when i run go install after running go build, i could find binary file in my current folder. Hence following Linux command was working

> $ go build && go install && ./executable

But after installing go 1.5, when i run same command i get,

> -bash: ./executable: No such file or directory

and when i checked, there is no executable to find. Did go install behavior changed in Go 1.5?

答案1

得分: 8

是的,行为在Go 1.5中已经发生了更改

>如果'go install'(没有参数,表示当前目录)成功,则删除由'go build'编写的可执行文件(如果存在)。这样可以避免在以下序列中留下陈旧的二进制文件:
>
go build
<测试,大部分工作正常,进行小改动>
go install
在此CL之前,当前目录仍然有来自'go build'的陈旧二进制文件。如果$PATH包含点,运行程序名称将找到此陈旧的二进制文件,而不是新安装的二进制文件。

我在发布说明中找不到任何提到这一点的内容。可能是一个文档问题。

看起来解决方案是使用go install生成的二进制文件。

编辑:这里是Go问题跟踪器上的问题,如果您想跟踪更新。应该在1.5.1中修复。

英文:

Yes, the behaviour has changed in Go 1.5:

>If 'go install' (with no arguments, meaning the current directory) succeeds, remove the executable written by 'go build', if present. This avoids leaving a stale binary behind during a sequence like:
>
go build
<test, mostly works, make small change>
go install
Before this CL, the current directory still has the stale binary from 'go build'. If $PATH contains dot, running the name of the program will find this stale binary instead of the new, installed one.

I can't find anything mentioning that in the release notes though. Might be a documentation issue.

It seems like the solution is to use the binary that go install has produced.

EDIT: Here is the issue on the Go issue tracker if you want to follow on updates. Should be fixed by 1.5.1.

huangapple
  • 本文由 发表于 2015年8月24日 18:48:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/32180434.html
匿名

发表评论

匿名网友

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

确定