6

i was working on a golang program and it was working correctly til yesterday, this morning i made some changes and get a build and every thing was fine then i tried to run the program through command line but this message showed up

k@kM:~/Projects/co-lib$ go run main.go
khaled@khaledM:~/Projects/co-lib$ go run main.go

Command 'go' not found, but can be installed with:

sudo snap install go # version 1.17.3, or sudo apt install golang-go # version 2:1.13~1ubuntu2 sudo apt install gccgo-go # version 2:1.13~1ubuntu2

See 'snap info go' for additional versions.

then tried to reinstall it , but oops ! i sow this message :

[sudo] password for khaled: 
error: This revision of snap "go" was published using classic confinement and
       thus may perform arbitrary system changes outside of the security
       sandbox that snaps are usually confined to, which may put your system at
       risk.
   If you understand and want to proceed repeat the command including
   --classic.

then downloaded the latest version and tried to install it with this order

sudo apt install go1.17.3.linux-amd64.tar.gz

but it shows another message again:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package go.1.17.3.linux-amd64.tar.gz
E: Couldn't find any package by glob 'go.1.17.3.linux-amd64.tar.gz'

blive me ! the location of the downloaded file is right in the home directory!

i am completely confused please help me

muru
  • 207,228

1 Answers1

27

You can install the (slightly older) version with apt,

sudo apt install golang

Alternatively, use the Golang Backports PPA, which hosts the latest version of golang for Ubuntu 18.04+.

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-1.17 

You can also install the latest version with snap,

sudo snap install go  --classic