M sharing here only the terminal commands for installing GO in Ubuntu 18.04...followed by checking whether it is working or not....
Commands as follows in yellow :
go to https://golang.org/dl/
Download the recent tar...herein it is go1.14.linux-amd64.tar.gz
Further to this untar the same...and move the files to /usr/bin
sudo tar -xvf go1.14.linux-amd64.tar.gz
sudo mv go /usr/local
cd /usr/local/
sudo chown -R root:root ./go
Using gedit or any other vi/vim editor, open the
~/.profile
file and append the following lines at the bottom :
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Save and load the commands vide the following command
source ~/.profile
Now create a new directory
mkdir GOLA
Within this create /src/welcome and within that directory copy and paste the contents of the file below
mkdir -p GOLA/src/welcome && cd GOLA/src/welcome
touch welcome.go
gedit welcome.go
add the following lines here in this file
package main
import "fmt"
func main() {
fmt.Printf("welcome to go world\n")
}
import "fmt"
func main() {
fmt.Printf("welcome to go world\n")
}
and save above followed by build and running the file
go build
./welcome
message should be displayed welcome to the go world