π± 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:
- β Have a working Go development environment
- β Know how to get the Go source code
π Prerequisites
Make sure you have the following installed:
- ποΈ Git
- πΎ At least 4GB of free disk space
β‘ Step 1: Install or Upgrade Go
β οΈ Important: You need an existing Go installation (version 1.24.6 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.6 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.6:
- π₯ Download Go: Visit https://go.dev/dl/ and download the appropriate installer for your operating system
- π οΈ Install Go: Follow the official installation guide for your platform:
- β Verify Installation: Open a new terminal and run:
go version
# Should show: go version go1.24.6 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. This might take a few minutes as it’s a large repository. β³
git clone https://go.googlesource.com/go
cd go
π·οΈ Step 3: Checkout Go Version 1.25.1
For consistency across the workshop, we’ll use Go version 1.25.1. Let’s check out the specific release tag: π
git checkout go1.25.1
Verify you’re on the correct version:
git describe --tags
# Should show: go1.25.1
π What We Accomplished
- β Installed or verified Go 1.24.6+ for bootstrapping
- β Cloned the official Go repository
- β Checked out Go version 1.25.1 for consistency
- β Environment is ready for building Go from source
β‘οΈ 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! π¨