2

I just followed the installation guide for golang (ubuntu 16). I extracted the archive at /etc/usr I added env variable in /home/user/.profile I just tested a basic go build on the hello world code.

I get the following error:

The program 'go' is currently not installed. You can install it by typing: sudo apt install golang-go

Why does it ask me to install it (again?)?

mbuechmann
  • 5,413
  • 5
  • 27
  • 40
Itération 122442
  • 2,644
  • 2
  • 27
  • 73
  • My guess would be because it's not been properly installed to start with! Can you provide a link to the installation guide you're referring to as well as the complete and exact steps you took? – Venantius May 27 '18 at 18:41
  • Don't include screen shots of text! Copy and paste the text directly into the question instead. – Jonathan Hall May 27 '18 at 20:31

9 Answers9

6
  1. open the go documentation download https://go.dev/dl/
  2. choice your os and go version
  3. download then extract the file
  4. extract the file
  5. open the file and open the terminal 6.Add /usr/local/go/bin to the PATH environment variable. export PATH=$PATH:/usr/local/go/bin
  6. then check the go version go version
Ridho MP
  • 121
  • 2
  • 3
5

The location of the binary go is not in your path. Ubuntu does not find it and suggests to install it. Add this line to your file /etc/profile, or better $HOME/.profile:

export PATH=$PATH:/usr/local/go/bin

This is documented in the docs: https://golang.org/doc/install#install

If you want to try this solution before editing any files, you can just execute the above command and try to execute the go command in the shell.

mbuechmann
  • 5,413
  • 5
  • 27
  • 40
4

There are paths which needs to be set correctly for you go installation to work

  1. GOROOT points to directory where go is installed

    export GOROOT=/usr/lib/go

  2. GOPATH points to you workspace directory

    export GOPATH=$HOME/go

  3. These paths need to be added in global path variable.

    export PATH=$PATH:$GOROOT/bin

Community
  • 1
  • 1
Ruchi
  • 41
  • 2
1

You need to put the go executable in your system path. which you can do by

export PATH=$PATH:/etc/usr/go/bin

You can put the same in /home/user/.profile

Prabesh P
  • 150
  • 4
0

just use asdf for installation. You can have several version also :D

Docs: https://asdf-vm.com/#/core-manage-asdf

Ardi Nusawan
  • 427
  • 6
  • 12
0

downlaod the installer form enter link description here, choose intaller for linux that suit your device and then you go to your CLI and use wget or curl :

$ wget https://storage.googleapis.com/golang/go1...

and then extract the file to /usr/local :

$ tar -C /usr/local -xzf go1...

add path binary Go to PATH environment variable :

$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
$ source ~/.bashrc

and then use go version to check if the Go already installed

0

If You are using linux then open your terminal and run this command.

sudo apt install golang-go

This command will Install Go lang. in your system. ThankYou

Abhinav Singwal
  • 467
  • 1
  • 3
  • 10
0

Steps for Go installation:

sudo apt-get update && sudo apt-get -y upgrade    
wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
sudo tar -xvf go1.17.5.linux-amd64.tar.gz
sudo mv go /usr/local/
export GOROOT=/usr/local/go

Add in .bashrc

vi .bashrc
export GOPATH="/root/go"
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
-1

Download latest version from https://golang.org/doc/install

tar -xzf go1.15.7.linux-amd64.tar.gz

move to /usr/lib/ to folder with version number

sudo mv go /usr/lib/go-1.15

create symkink link on /usr/bin/

ln -s /usr/lib/go-1.15/bin/go /usr/bin/go
OLS
  • 155
  • 15