I am new to Ubuntu and am trying to install Go onto my server, however I get an error when trying to use Go.
Command 'go' not found, but can be installed with:
sudo apt install golang-go # version 2:1.13~1ubuntu2, or
sudo apt install gccgo-go # version 2:1.13~1ubuntu2
The commands I used to install Go are below.
$ wget https://dl.google.com/go/go1.15.10.linux-amd64.tar.gz
$ sudo tar -xvf go1.15.10.linux-amd64.tar.gz
$ sudo mv go /usr/local
Then I appended the following to the bash_aliases file.
$ vi ~/.bash_aliases
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
What am I doing wrong here?
CodePudding user response:
I will give you some suggest.
- check your path var
echo $PATH
Since you edit ~/.bash_aliases, I think you maybe not source this file.
please try source ~/.bash_aliases
.
or try
export $PATH=$PATH:/usr/local/go/bin
beside ~/.bash_aliases
may not be load by default. see if . ~/.bash_aliases
is in your ~/.bashrc
file.
- Check if bin can run
/usr/local/go/bin/go version
if have error, maybe is the package you download is wrong. checksum the tar package(for example: md5sum xxxx.tar.gz
).
- check the default path of go
which go
if go bin not in /usr/local/go/bin/go, you should delete the go bin that shown by which go
CodePudding user response:
Using APT, there is an official package you can install using Ubuntu
Open a terminal and run:
sudo apt update
sudo apt install golang-go
Depending on your version of Ubuntu, you may have to run:
sudo apt install golang
Hope this helps! Its my first answer!