How to Install & Run Go programming language on Ubuntu – Golang

Go or Golang is a free and open source concurrent, functional, imperative and object-oriented programming language for Linux, macOS, Windows, BSD and created by Google. It comes with some advantages like memory safety, garbage collection and structural typing. Some famouse projects written in Go are Docker and Kubernetes, Google’s download server, hootsuite, Crowdfire and many more. Emacs, Vim, VSCode, Atom, Eclipse, Sublime and IntelliJ provides support for go language.

Install Go programming language on Ubuntu:

Download Go binary:

Go to the above go language download page and download the latest Linux version. Here the downloaded file name “is go1.14.2.linux-amd64.tar.gz“. Right click on this file and select Extract Here option. You will get “go” folder.

Then open your file manager in root mode. If you are using nautilus file manager, then use this command.

sudo -E nautilus

If your file manager is thunar (xfce), then

sudo -E thunar

Then copy the go directory and paste it to the /usr/local folder.

[Or]

you can also do this all by running below command in your terminal app (ctrl+alt+t)

wget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

Here the current version is 1.14.2 and download url for the linux version is https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz You can change this url based on your download link. you can check this from above go binary download link.

Suggested Read:  AstroMenace 3D space scroll-shooter - How to install AstroMenace on Ubuntu

Then add Go folder path to the $PATH environment variable. In terminal

export PATH=$PATH:/usr/local/go/bin
source ~/.profile

Restart your system and verify the installation by

go version

if you get any error. run this again.

export PATH=$PATH:/usr/local/go/bin
source ~/.profile

Run Go Hello World Program:

Create go/src/connectwww folder inside username folder. Or run this command to create it.

mkdir -p ~/go/src/connectwww

Go to the created connectwww folder and create a file called “connectwww.go

Open that file and write the below code and save it.

package main

import (
"fmt"
)

func main() {
fmt.Println("Hello, CONNECTwww.com")
}

Then navigate to go/src/connectwww in terminal.

cd go/src/connectwww

Then build the program using below coomand.

go build

Then run

./connectwww

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on Twitter and Facebook.

You may also like...

Leave a Reply

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