Golang installation

2.6k Views Asked by At

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?)?

9

There are 9 best solutions below

0
On BEST ANSWER

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.

0
On

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

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

0
On

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
On

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
0
On
  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
0
On

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

0
On

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
0
On

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

0
On

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