How to Install Golang 1.13 on CentOS 8, Ubuntu 18.04, Debian 10, and Fedora 31

Updated on March 5, 2020
How to Install Golang 1.13 on CentOS 8, Ubuntu 18.04, Debian 10, and Fedora 31 header image

Go (also known as Golang) is a statically-typed, compiled, C-like programming language developed by Google. Go's simplicity and versatility has made it to be the preferred language for developing high-performance web applications and microservices.

Go can be installed in both 32-bit & 64-bit Linux Operating Systems. Though these steps are written for CentOS, Ubuntu, Debian, and Fedora, it is applicable for any Linux distribution.


Before getting started, make sure you have

  • A Vultr CentOS 8, Ubuntu 18.04, or Debian 10 VPS instance
  • A user with root privileges


Log in to your Vultr instance via SSH.

Step 1: Download and Unzip Go 1.13 archive

Go's build, runtime, and language-support tools are available as a TAR archive for Linux. The installation process:

  • Download the archive using wget.
  • Extract it using tar to the /usr/local path.
  • Remove the downloaded package.

Example commands for 64-bit systems

sudo tar -zxvf go1.13.6.linux-amd64.tar.gz -C /usr/local
rm go1.13.6.linux-amd64.tar.gz -f

Example commands for 32-bit systems

sudo tar -zxvf go1.13.6.linux-386.tar.gz -C /usr/local
rm go1.13.6.linux-386.tar.gz -f

At the time of writing this guide, the latest available version was 1.13. You can check the latest Go version from the Go official download page.

Step 2: Setup Environment variables

The Go's runtime and build executables are now available under /usr/local/go/bin. Add the executable path to PATH environment variable. Add the GOROOT environment variable referencing your local Go installation. Use thesource command to reload the updated values.

echo 'export GOROOT=/usr/local/go' | sudo tee -a /etc/profile
echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile
source /etc/profile

Step 3: Verification

Now, let's verify the Go setup.

go version

This should print out the current version.

go env 

This should print out all the flags. If so, you have set up the Go installation in your system successfully.

OPTIONAL: A quick Hello World program

Let's write the Hello World application to test our setup.

  1. Create a folder and navigate into it.

     mkdir hello
     cd hello   
  2. Create a Go module using the go mod command.

     go mod init hello
  3. Create a file named hello.go

     touch hello.go
  4. Edit the file hello.go.

     vi hello.go
  5. Once inside the vi editor, press I to switch to 'Insert' mode

  6. Enter the following code snippet in the editor.

     package main
     import "fmt"
     func main() {
         fmt.Printf("Hello World!")

Executable Go programs start with package main. We imported the fmt package, which provides methods to print text.

  1. Save the file by pressing Esc and type WQEnter

  2. Run your first Go application

     go run hello.go
  3. You should see the output:

     Hello World!

You have successfully set up Go and written your first application.