How ToLinux

How to Install Go on Ubuntu

What is Go?

Go is an open source, compiled, concurrent, garbage-collected, statically typed language developed at Google. Google created it to solve its own problems in relation to multicore processors, networked systems and large codebases. While languages such as C and C++ are fast, they are hard to master and development takes longer. While Python is easier to work with, it compromises on runtime efficiency. Go was designed to be efficient, scalable and productive. This programming language designed by Google engineers Robert Griesemer, Rob Pike, and Ken Thompson.

Install Go

  • Use curl or wget to download the current binary for Go from the official download page. As of this writing, the current version is 1.11 Check the download page for updates, and replace 1.11 with the most recent stable version if necessary.
curl -O
  • Extract the tar file:
tar -xvf go1.11.linux-amd64.tar.gz
  • Adjust the permissions and move the go directory to /usr/local:
sudo chown -R root:root ./go
sudo mv go /usr/local

Adjust the Path Variable

Using a text editor, open the ~/.profile file and add the following two lines to the bottom of the file:

export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Save the file, and load the commands into the current shell instance:

source ~/.profile

Test the Installation

According to the official documentation, the following steps are the recommended way to test the success of the installation:

In your home directory create a folder named go, this will be your workspace:

mkdir go

Within that directory create /src/hello and within that directory copy and paste the contents of the file below:

mkdir -p go/src/hello && cd go/src/hello
touch hello.go
package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")

Build the hello.go file:

go build

Run the script:


hello, world

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *