How to Set Up a Go Development Environment on Linux

Go, also known as Golang, is a modern and efficient programming language developed by Google in 2007. Its popularity has grown significantly in recent years thanks to its simplicity, speed, and concurrent features.

If you are a developer who wants to explore this language, you need to set up a Go development environment on your system. Let’s learn how you can install Go on Linux manually and using the package manager.

4

Prerequisites to Install Go on Linux

Before installing Go on Linux, you need to ensure that your system is up-to-date. Open a terminal and execute the following command to do this:

On Ubuntu- andDebian-based Linux distros:

GO logo in foreground code in background

On Arch Linux and its derivatives:

On RHEL and Fedora:

manually downloading and installing go

Once you’ve updated and upgraded your system, you’re ready to move on to the next steps.

Method 1: Install Go on Linux With the Package Manager

Once your system is up-to-date, you’re able to proceed to install Golang via the default package manager of your Linux distro.

On Ubuntu- and Debian-based Linux distros:

uninstalling golang using APT package manager

That’s all the steps required to install Go on your Linux machine using the default package manager.

Method 2: Manually Download and Install Go on Linux

To manually install Go on your Linux machine, first, you’ll need to grab the latest Go TAR package from the official Golang site. You can do so manually or usingthe wget command on Linux:

Download:Go (Linux)

uninstall go manually

Now you need to untar the package into the recommended default directory (you can change this as per your liking) using a sudo prefixed tar command with the-xvftag:

Next, add the directory where you untarred the package to the PATH environment variable. You can do so using the export command:

That’s all the steps you need to manually install Go. You can verify the installation by running the following command:

This command should return the version of Go that’s currently active on your system.

Uninstall Go From Your Linux System

If you want to uninstall Go, you can do that by following one of two ways, depending on how you installed it in the first place. If you installed Go using the package manager, you can uninstall it the same way you would remove other programs.

If you installed Go manually, you can uninstall it by simply cleaning the Go installation directory.

In case you installed it in the recommended default directory, run this command:

If you installed it into a different directory, just replace the location with your own installation directory. You may also want toupdate the PATH variableto remove the Go directory.

Now You Can Build Software With Go on Linux

With a Go development environment set up, you may start exploring the language and building your applications. You can use Go to build anything, from web applications to command-line tools and cloud services.

Go’s features, third-party package support, and general flexibility give developers creative liberty to build all sorts of software. If you’re new to Go development, there are a few things you need to know to take advantage of Golang’s full potential.

Get up to speed with this primer on the Go language.

If an AI can roast you, it can also prep you for emergencies.

Tor spoiled me forever.

Anyone with more than a passing interest in motorsports must see these films.

So much time invested, and for what?

Some subscriptions are worth the recurring cost, but not these ones.

Technology Explained

PC & Mobile