Go commands doesn't work ok Kali Liunx

Hi guys, i use go on windows and there it works fine. Now i have to use it on another pc with Kali Linu. So i have followd the steps from the documentation to install go. But when i launch go version or go build nothing works. Here is my PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin"
Any suggestion?

Running Go Version would not work because the executable is go.

Run ls /usr/local/go/bin to see the correct names. If this does not include go, then your installation is broken or you installed to a different location.

I used go version and not Go Version. Same for Go build. I have edit yet my question. Iā€™m sorry for that.
By the way, the output of the command ls /usr/local/go/bin is: go, godoc and gofmt

What is the output from running echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/locale/go/bin

/usr/locale/go/bin is misspelled. It should be /usr/local/go/bin.

Now when i run go version i get this error bash: /usr/local/go/bin/go: cannot execute binary file: Exec format error

What is the output of file /usr/local/go/bin/go

Here is it: /usr/local/go/bin/go: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, not stripped

Is your kali linux 32bit? (You can check by running uname -a)

I was sure that my kali linux was 64 bit :disappointed_relieved: Thank you for your help!

Use the linux whereis command to get information about the go installation folder.
whereis go

IN my case: /usr/bin/go

You now need to set the path

echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
echo 'export GOROOT=/usr/bin/go' >> $HOME/.bashrc

Update your package
source $HOME/.bashrc
And check the variables
go env

The problem here was trying to run a 64-bit go on a 32-bit linux.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.