All of a sudden go tool: no such tool "compile"

Issue

I had installed go on my Ubuntu desktop and it worked fine before I switch off the computer.

Now as I started my machine and resumed my work on the project, I get this

$ go build
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"

When I try to build a project.

The only thing that I did before poweroff which might have some effect was to install godoc using

sudo apt-get install golang-doc

I had install go directly by downloading go1.10.1.linux-amd64.tar.gz file, not using apt-get

go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/me/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build255010769=/tmp/go-build -gno-record-gcc-switches"

$ go version

go version go1.10.1 linux/amd64

I can still run comiled go code.

What could have gone wrong here? How can I fix it?

Solution

The compile program should be in your go env GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" directory. If not, download Go, delete /usr/local/go, and reinstall Go.

Answered By – peterSO

Answer Checked By – Jay B. (GoLangFix Admin)

Leave a Reply

Your email address will not be published.