How to install Go on ubuntu 20.04
Go is a statically typed, compiled programming language designed at Google.Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
In this tutorial, we will explian on how to install go programming language on ubuntu 20.04 system. we can install go using two methods.
Method1: Install Go through binary release
we will install latest version of go as we have to download from its official website.you can downlad and extract it with the following commands.
cd /usr/local
wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz
tar -xvzf go1.16.4.linux-amd64.tar.gz
once file is extracted, you can set system-wide environment variables as below.
nano ~/.bashrc
set below path at the end of above file.
export PATH="/usr/local/go/bin/:$PATH"
save the file and load the new PATH environment variable.
source ~/.bashrc
now check go version using the following command.
go version
sample output:
go version go1.16.4 linux/amd64
Also Read -> How to Install Python 3 9 on Ubuntu 20 04
Method 2: using ubuntu standard repo
we will update the repository using apt.
sudo apt update
then install go language using the following command.
sudo apt install golang-go
now you can check go version using below command.
go version
Also Read -> How to Install MySQL 8 on Ubuntu 20 04
Testing
just create text file as hello.go and paste below content.
package main
import "fmt"
func main() {
fmt.Printf("Hello!\n")
}
save the file and run the file as below.
go build hello.go
its creates hello bianry and run it.
./hello
sample output:
Hello!
That's it. Now we have successfully installed go on ubuntu 20.04 system.
Also Read -> How to Install ReactJS on Ubuntu 20 04