Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Installing and Setting Up Go on Linux

Getting started with any programming language requires some initial setup, and Go is no different. Occasionally, the setup of compiled languages can be tricky, but thankfully Go has a fairly painless setup. In this learning activity, you've been asked to set up a development server for your boss who wants to learn Go but doesn't want to go through the setup. By the time you've finished this activity, you should feel comfortable setting up a Go development environment.

Google Cloud Platform icon

Path Info

Clock icon Beginner
Clock icon 1h 0m
Clock icon Jan 21, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Download and install Go (version 1.11.x)

    To install Go, we need to download the package for our server's operating system and CPU architecture from the Go downloads page. The server we've been given is running 64-bit Linux, so we'll need the linux-amd64 version.

    After the package is downloaded, it should be extracted and moved to /usr/local. Here's one way we can achieve this for version 1.11.2:

    ~ $ cd /tmp
    /tmp $ wget
    /tmp $ sudo tar -C /usr/local -xzf go1.11.2.linux-amd64.tar.gz

    We'll also want to install git:

    ~ $ sudo yum install -y git
  2. Challenge

    Set up the `$GOPATH`

    When developing with Go, the source code needs to be placed in the $GOPATH, and that directory tree needs to be manually set up. We need to create the directories at ~/go, ~/go/bin, and ~/go/src. Once these directories are set up, then we'll also need to set up the $GOPATH environment variable.

    ~ $ mkdir -p ~/go/{src,bin}
    ~ $ echo 'export GOPATH=$HOME/go' >> ~/.bashrc
  3. Challenge

    Modify `$PATH` to include Go binaries

    The Go package we downloaded comes with its own binaries, but we won't have access to them until they are placed within our $PATH. We need to append the /usr/local/go/bin and $GOPATH/bin directories to our $PATH in the .bashrc file.

    /tmp $ cd ~
    ~ $ echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.bashrc
    ~ $ source .bashrc
    ~ $ go run hello.go
    Thank you for setting up this server!
    ~ $

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans