How to Install GoLang on Ubuntu Server 20.04 LTS: Cannot Execute Binary File

I'm trying to install Golang on my raspberry pi running ubuntu server 20.04LTS and am having a lot of trouble. I could probably use advice on how to make sure I undo and uninstall any changes I made while attempting to install go-lang via snap and apt-get. I have successfully installed the package from tar.gz found at go.dev into the correct location /usr/local/ But no matter how many instructions I follow on exporting the path I always get this same error.

enter image description here

I have cleared out my path in order to prep for getting help

enter image description here

And I have extracted /go from the go.dev tar.gz file

enter image description here

Please I really could use some help with the appropriate installation procedure.

What is the correct method? snap or apt-get?

How are the variables actually supposed to be set?

How do I make sure I uninstall everything I did wrong and reinstall the right way ?

I have tried several times to compile it manually by unzipping from tar.gz but even when I try running ./go/bin/go directly I still get the error -bash: ./go/bin/go: cannot execute binary file: Exec format error

two commands I ran troubleshooting that Im not sure how to undo.. or if i need to.

sudo update-alternatives --set go /usr/local/go/bin/go

sudo update-alternatives --install "/usr/bin/go" "go" "/usr/local/go/bin/go" 0

3

1 Answer

You have to remove wrongly manually installed Go executable by

sudo rm /usr/local/go/bin/go

and then install normal one from official repositories by:

sudo apt-get install golang-go

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like