Let’s Go! – Installing the Go programming language on Debian

Go keeps growing and increasing in popularity as it evolves, leaving many to wonder if it is the eventual replacement of programming languages such as Python, Java, C++, and others.


Go, also referred to as Golang, is an open-source, lower-level, statically typed programming language created by Google.

A team of Google programmers (Robert Griesemer, Rob Pike, and Ken Thompson) developed Go in 2007.  Go’s primary purpose is building fast, simple, efficient, and reliable server-side and web-based applications.

Some commonly known open source applications written with Go include Dockers, Lime, InfluxDB, Kubernetes, etcd, and Terraform.  Go keeps growing and increasing in popularity as it evolves, leaving many to wonder if it is the eventual replacement of programming languages such as Python, Java, C++, and others.

“[Go] really feels like “the C for the 21st century.”

– Petr Hosek, Google Senior Software Engineer

Installing Go

Installing Go on your Linux distro is effortless.


Installing Go is effortless.
Installing Go is effortless.

Open a terminal window (<Ctrl><Alt>T).  At the command prompt, enter:

# sudo apt-get install golang

Press Y when prompted.

Configuring Golang Environment


Before using Go, we must first configure and setup our environment.

First, we must edit our ~/.profile file to add a GOPATH variable and add our Go working subdirectory to our PATH.

Edit ~/.profile file to add the GOPATH variable Go working subdirectory PATH.
Edit ~/.profile file to add the GOPATH variable Go working subdirectory PATH

Use your favorite text editor and add the following lines:


to the end of ~/.profile.  When satisfied with your edits, save the file.

Next, we need to load our new PATH variables into our current shell instance.

Reload the new PATH variables current shell instance.
Reload the new PATH variables’ current shell instance

# source ~/.profile

Although our updated PATH is loaded, we still have to create the subdirectory it refers to.

Create the Go working and project directories.
Create the Go working and project directories

# mkdir -p golang/src/sample && cd golang/src/sample

Notice that the first command (mkdir -p golang/src/sample) creates both directories that we need for our Go environment

  • The workspace directory (~./golang/src).
  • The project directory (~./golang/src/sample), where ‘sample‘ is our project directory.  Each Go project you create should have its subdirectory within ~./golang/src.

Of course, the second part of your command merely changes us to our project directory (~./golang/src/sample).

Create and Test Your First Go Program

Now, let’s create and test our first program.  Since we’re already in our project directory, use the text editor to create our first project source file.

Creating our first Go program.
Creating our first Go program

Add the following lines to the blank file:

package main

import "fmt"

func main() {
fmt.Printf("Hello, FOSS Linux Readers!\n")

Save your file as sample.go.  Now let’s compile our new program.

Compiling our sample Go profile.
Compiling our sample Go profile

While still in the ~./golang/src/sample subdirectory, enter

# go build

After our program compiles, let’s test it.

Running ./sample - Hello FOSS Linux Readers!
Running ./sample – “Hello FOSS Linux Readers!”

# ./sample

Congratulations!  You’ve just built and successfully tested your first Go program.  Exciting isn’t it!

The Go programming language offers Linux users a great tool to not only learn a new programming language (or programming in general) but also allows for the quick creation of simple programs. They run fast and efficiently, not only in the Linux environment but also in Mac, Windows, and Android environments, as Go is a cross-platform language.

If so inclined, please install and test out Go.  ‘Go‘ ahead and create more sample programs with Go. Let us know how it turns out.

Here are a few websites to help you on your journey:

Good luck!

Travis Rose
Hi, I'm M Travis Rose, a contributor to FOSS Linux. I have over thirty years of experience in the IT arena, at least fifteen of which has been working with Linux. I enjoy converting existing Windows users to the wonderful world of Linux. I guess you could call me a Linux-evangelist. Long live Linux!


Please enter your comment!
Please enter your name here




Top 20 Git Commands with Practical Examples

If you are here reading this post, there is a high probability that you have heard or interacted with Github, and you now want to learn Git. Before we continue with showing you some of the cool Git commands, let's understand the difference between Git and GitHub.

Top 10 New Features in Linux Kernel 5.7

Linus Torvalds has announced the release of Linux Kernel 5.7 after seven weeks of development. The release announcement comes as a piece of exciting news as it brings a host of new features for the hardware manufacturers as well as the developers.

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

What’s New in Ubuntu 20.04 LTS “Focal Fossa”

Ubuntu 20.04 LTS is out now! This is the successor to Ubuntu 18.04, which was released in April 2018 and still has three years of official support left. Code-named Focal Fossa, the new edition has all the bells and whistles included in it, making it one of the best Ubuntu releases yet. Let's find out more.

Top 5 reasons to switch from Windows to Linux right now

Do you love Windows or Linux? Being on a Linux website, it's not hard to take a guess, but what are the strong reasons to switch to Linux? Linux is a 100% free OS. Is that reason alone enough? Let's find out! Never have there been more compelling reasons to make the switch. Here are just five great reasons for users to create that magical move from the wayward world of Windows to the lauded land of Linux.

Enabling GameMode on Linux for best gaming performance

GameMode is a combination of various libraries and daemons that allows all the users to improve the gaming performance on the Linux system. Developed by games publisher Feral Interactive, it improves gaming performance by requesting a group of options that will be applied temporarily to the Linux system.

6 Essential Command-Line Utilities Every Linux User Should Know

Last week, we shared with you several "cool and fun" commands to get comfortable and confident with the Linux command-line. In our quest to further aid Linux users with mastery of the command line, or CLI, we present you with a variety of command-line utilities essential for all Linux users, regardless of proficiency level.