- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

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.

Lab Info
Table of Contents
-
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 version1.11.2
:~ $ cd /tmp /tmp $ wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz /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
-
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
-
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! ~ $
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.