Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

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?

like image 756
Karlom Avatar asked Jul 05 '18 01:07

Karlom


3 Answers

It may seem odd, but running export GOROOT= fixed the issue for me.

like image 117
Oleg Avatar answered Oct 23 '22 06:10

Oleg


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.

like image 10
peterSO Avatar answered Oct 23 '22 05:10

peterSO


I was facing the same issue in my MAC M1.

Previously, I had downloaded it using "brew". I tried downloading it manually and reinstalling it. That worked for me.

go version: 1.18.2 Download: https://go.dev/dl/

like image 1
Alok Tripathi Avatar answered Oct 23 '22 06:10

Alok Tripathi