[英]go tool: no such tool "compile"
I recently started trying go to program some web based applications.我最近开始尝试编写一些基于 Web 的应用程序。 At first, everything went fine, until I wanted to cross compile a binary for a different platform.起初,一切都很顺利,直到我想为不同的平台交叉编译二进制文件。 I'm running MacOS and I wanted to compile a binary for linux, so I changed GOOS
to linux
and GOARCH
to amd64
.我正在运行 MacOS,我想为 linux 编译一个二进制文件,所以我将GOOS
更改为linux
并将GOARCH
为amd64
。 Since then, I always get the error message从那以后,我总是收到错误消息
go tool: no such tool "compile"
I'm using GoClipse, but running the compile manually by我正在使用 GoClipse,但手动运行编译
go install hello.go
I get the same error.我犯了同样的错误。 When changing back to compiling for darwin architecture, I get the same error now, so basically I'm totally unable to compile any code written in Go at the moment.当改回为达尔文架构编译时,我现在得到了同样的错误,所以基本上我现在完全无法编译任何用 Go 编写的代码。
I installed it via the binary packages provided by google. 我通过谷歌提供的二进制包安装它。 In the end I actually got it back to work by just reinstalling it. 最后,我实际上通过重新安装它重新开始工作。 Sometimes I'm just blind to the easy solution. 有时我只是对简单的解决方案视而不见。
After that, I succeeded in cross compiling for linux machine after compiling the necessary cross-compilers by running env GOOS=linux GOARCH=arm GOROOT_BOOTSTRAP=/usr/local/go ./make.bash --no-clean
from the Go sources directory. 在那之后,我通过从Go源目录运行env GOOS=linux GOARCH=arm GOROOT_BOOTSTRAP=/usr/local/go ./make.bash --no-clean
编译了必要的交叉编译器,成功地为linux机器进行了交叉编译。 。
Thanks for all you efforts, sorry to have kept you busy on such a simple matter. 感谢您的所有努力,抱歉让您忙于这么简单的事情。
如果你安装Go 1.5,你可能可以逃脱,但是如果你使用依赖于cgo
任何东西,你将不得不安装一个交叉编译器链接器或在虚拟机上安装Linux以便能够交叉编译Linux 。
In my case is due to the fact that GOPATH and GOROOT are not set correctly, maybe you can check go env
. 在我的情况下,由于GOPATH和GOROOT设置不正确,也许你可以检查go env
。 Here is a discussion may be useful. 这是一个讨论可能有用。
You have the wrong x64 or x386 package installed most likely. 您最有可能安装了错误的x64或x386软件包。 I had 32 installed running 64 bit. 我安装了32位64位运行。 Reinstall fixed. 重新安装修复。 Good luck. 祝好运。
The way I figured-out what file is read and caused Go to look for the compile binary in the wrong place can be solved using: $ strace go tool -n compile 2>&1 |grep openat我弄清楚读取了什么文件并导致 Go 在错误位置查找编译二进制文件的方式可以使用以下方法解决: $ strace go tool -n compile 2>&1 |grep openat
openat(AT_FDCWD, "/home/nwaizer/.config/go/env", O_RDONLY|O_CLOEXEC) = 3
In that file, the IDE Goland, add a path to some project, causing the havoc.在那个文件中,IDE Goland,添加了一些项目的路径,造成了破坏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.