Exercise 0: Introduction and Setup

Welcome to the Go Source Code Workshop! In this introductory exercise, you’ll set up your environment and get familiar with the Go source code repository.

Learning Objectives

By the end of this exercise, you will:

Prerequisites

Make sure you have the following installed:

Step 1: Install or Upgrade Go

⚠️ Important: You need an existing Go installation (version 1.24 or newer) to build Go from source. This is called “bootstrapping” - using an existing Go compiler to build the new one.

Check Your Current Go Version

go version
# Should show: go version go1.24 or higher

If Go is Not Installed or Too Old

If you don’t have Go installed, or your version is older than 1.24:

  1. Download Go: Visit https://go.dev/dl/ and download the appropriate installer for your operating system
  2. Install Go: Follow the official installation guide for your platform:
  3. Verify Installation: Open a new terminal and run:
   go version
   # Should show: go version go1.24 or higher

Installation Help: If you need detailed installation instructions, see the official Go installation guide.

Step 2: Clone the Go Source Code

Let’s clone the official Go repository. We use --depth 1 to avoid downloading the full history, making the clone much faster:

For consistency across the workshop, we’ll use Go version 1.26.1.

git clone --depth 1 --branch go1.26.1 https://go.googlesource.com/go
cd go

Step 3: Verify Go Version 1.26.1

Verify you’re on the correct version:

git describe --tags
# Should show: go1.26.1

What We Accomplished

Next Steps

Perfect! Your environment is now set up and ready. In Exercise 1: Compiling Go Without Changes, you’ll build the Go toolchain from source and explore the Go compiler structure while it’s building!