'go tool: no such tool "compile"
I recently started trying go to program some web based applications. 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. Since then, I always get the error message
go tool: no such tool "compile"
I'm using GoClipse, but running the compile manually by
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.
Solution 1:[1]
You have the wrong x64 or x386 package installed most likely. I had 32 installed running 64 bit. Reinstall fixed. Good luck.
Solution 2:[2]
You might be able to get away with that if you install Go 1.5, however if you use anything that depends on cgo, you will have to install a cross-compiler linker or install Linux on a virtual machine to be able to cross compile for Linux.
Solution 3:[3]
In my case is due to the fact that GOPATH and GOROOT are not set correctly, maybe you can check go env. Here is a discussion may be useful.
Solution 4:[4]
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
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andy |
| Solution 2 | OneOfOne |
| Solution 3 | Kehe CAI |
| Solution 4 | Niv Waizer |
