The objective of this guide is to install Go/Golang on Ubuntu 20.04 Focal Fossa Linux. Go also know as Golang, is an open source programming language developed by Google. Go also know as Golang, is an open source programming language developed by Google. Install Ubuntu 17.04. Ubuntu 17.04 ('Zesty Zapus') is the latest and the current version of a famous desktop operating system from Canonical.Ubuntu 17.04 has been released on 13 April 2017; it will be supported for nine months until January 2018. In this video - 'How To Install Go In Ubuntu', I will walk you through the steps for Installing Go1.10 in Ubuntu. The installation will not take more than 5. In this article, I will take you through the steps to Install GO Using APT GET on Ubuntu 18.04. Go, sometimes referred to as golang to make it easier to find on the web, is a statically typed and compiled open source programming language initially developed by Google.
Go is an open-source programming language developed by a team at Google. It provides easy to build simple, reliable, and efficient software. This language is designed for writing servers, that's why it is using widely these days. Go has released the latest version 1.15.
This tutorial will help you to install Go 1.15 on your Ubuntu 19.10, 18.04 LTS, 16.04 LTS, and 14.04 LTS systems.
Step 1 – Install Go on Ubuntu
Login to your Ubuntu system using ssh and upgrade to apply latest security updates there.
Now download the Go language binary archive file using following link. To find and download latest version available or 32 bit version go to official download page.
Now extract the downloaded archive and install it to the desired location on the system. For this tutorial, I am installing it under /usr/local directory. You can also put this under the home directory (for shared hosting) or other location.
Step 2 – Setup Go Environment
Now you need to setup Go language environment variables for your project. Commonly you need to set 3 environment variables as GOROOT, GOPATH and PATH.
- GOROOT is the location where Go package is installed on your system.
- GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 .
- Now set the PATH variable to access go binary system wide.
All the above environment will be set for your current session only. To make it permanent add above commands in ~/.profile file.
Step 3 – Verify Installation
At this step, you have successfully installed and configured go language on your system. First, use the following command to check the Go version.
Now also verify all configured environment variables using following command.
Conclusion
In this toturial, you have learned to install and configure Golang on Ubuntu Linux system.
In this tutorial, I will take you through the steps to Install Golang on Ubuntu 18.04. It was created by small team in Google which consists of Robert Griesemar, Rob Pike and Ken Thompson. GO is a strong and statically type language.
Strong type means type of a variable cannot change over time. It means if you declare a variable to hold an integer, it will always hold an integer. You cannot put any boolean or string value in it. Static type means all of the variables has to be defined at the compile time.
Why GO Language?
At the time GO was created, we had few powerful languages available at that time i.e Python, Java and C/C++. But over the time, we had certain limitations with these languages. For e.g:-
a)Python is easy to use but it is little slow.
b)Java program has becoming increasingly complex type system.
c)C/C++ also becoming complex over the time and hence compile time is getting slower.
So GO language is created by optimizing the compiler and improving the compile time. You will know more about GOLANG in next few tutorials. Let's follow the steps to install GOLANG in this tutorial.
Install GOLANG On Ubuntu
Before going through the steps to install golang in your system, you need to ensure prerequisites are met.
Also Read:Networking in Docker with Best Examples
Step 1: Prerequisites
a)You must have a running Ubuntu 18.04 System.
b)You need to login as root user or user with sudo access to run below commands. You can visit How to add User into Sudoers on Ubuntu 18.04 to check the steps to add User into Sudoers.
Step 2: Update Your System
You need to update your system using sudo apt-get update
command.
Golang Ubuntu Install
Step 3: Download Golang Tar file
You can go to GOLANG Download Page and download tar file for Linux using wget command. This will download go1.13.6.linux-amd64.tar.gz in current directory.
Step 4: Extract Tar File
Once golang tar file is downloaded, you need to extract the compressed file by using tar
command as shown below.
Step 5: Setting Up the Directory
Move extracted go/ directory to /usr/local using below command.
Now you need to create a go/ directory in /home/test which will used as Project Workspace. You can choose any name you want for creating workspaces. It really does not matter.
Set the Path at the end of ~/.profile. You need to ensure that .profile is required to be set for all those users through which you want to build and run your GO Programs.
Step 5: Setting Up the Directory
Move extracted go/ directory to /usr/local using below command.
Now you need to create a go/ directory in /home/test which will used as Project Workspace. You can choose any name you want for creating workspaces. It really does not matter.
Set the Path at the end of ~/.profile. You need to ensure that .profile is required to be set for all those users through which you want to build and run your GO Programs.
Once profile is edited and saved. You need to load the Profile Again by using below command.
Step 6: Check GO Version
Once GO Path is set, you can check the GO Version by running go version
Download the google chrome new version. command as shown below.
Step 7: Write Your First GO Program
Create another directory example under go directory. We will write our first GO Program in this directory.
Install Golang Ubuntu 18.04
Then, write a simple hello World program in hello.go
as shown below. We will use our favourite editor nano to open the file and write our code.
Step 8: Build Your GO Program
Now build your program with go build
command as shown below.
If you don't receive any error after completing the build then you need to check if the executable got created or not by running ls
command. You can see your executable example
got created.
Step 9: Test Program Output
Now you can run your Program and test the output as shown below.
Also Read:Top 15 tools to monitor disk IO Performance with Examples