0

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

1
  • 4
    Hi, FYI "sudo apt install go1.17.3.linux-amd64.tar.gz" is incorrect. If you use the repos, then check "apt-cache search golang" for package names, then install via eg. "apt install golang-1.16" etc. If you download the source (not recommended), then you need to compile. You need to google the basics of Ubuntu package installation first.
    – sarlacii
    Nov 24, 2021 at 8:51

1 Answer 1

14

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
1
  • The backports work for WSL too.
    – yshehab
    Jul 18, 2022 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .