One-day workshop · Go 1.26.1

Go Mechanics Workshop

A hands-on workshop exploring Go's internals — from the compiler pipeline to the runtime scheduler, memory allocator, and garbage collector. Modify the Go source code to deeply understand the machinery behind the language.

Duration
~8 hours
Format
Theory + labs
Exercises
14
Go
1.26.1
Workshop Overview

14 exercises covering the full Go stack.

This workshop has 14 exercises covering the full Go mechanics stack — compiler pipeline, memory allocator, garbage collector, goroutine scheduler, and core data structures. Each section is a hands-on exercise where you modify Go itself:

00

Introduction and Setup

Set up your environment by installing Go and cloning the Go 1.26.1 source code.

01

Build Go from Source

Bootstrap the Go toolchain from source and explore the compiler and runtime directories.

02

Lexer & Scanner — Arrow Operator

Add '=>' as an alternative goroutine syntax by modifying the scanner.

03

Parser — Multiple 'go' Keywords

Allow 'go go go fn()' syntax by modifying the parser.

04

Escape Analysis & Inlining — The Greedy Inliner

Tune the inlining budget, measure binary size, and find the runtime's hard ceiling.

05

SSA & Compiler Backend — Power-of-Two Detector

Create a custom SSA pass that finds divisions by powers of two.

06

Memory Allocator — The Superstitious Allocator

Make the allocator panic on unlucky allocation sizes to expose the internals.

07

Goroutine Stack — Big-Boned Goroutines

Start every goroutine with a 1MB stack and observe the memory impact.

08

GMP Scheduler — Patient Go

Make the runtime wait for all goroutines before the program exits.

09

Work Stealing — D&D Dice Roll

Gate goroutine theft with a d20 dice roll.

10

Garbage Collector — Anxious GC

Make the GC run aggressively by lowering its trigger threshold.

11

Slices & Maps — Explosive Growth

Change the slice growth factor to 10x and make maps rehash obsessively.

12

Channels & Select — Predictable Select

Remove randomness from select to make it always pick the first ready case.

13

Panic & Defer — Java-Style Stack Traces

Transform Go's stack traces to look like Java's.

Before you start

Prerequisites

You should know / have

  • Solid knowledge of Go programming
  • Familiarity with command line tools
  • Git installed on your system
  • Go compiler version 1.24.6 or newer (required for bootstrapping the build)
  • At least 4GB of free disk space
  • A curious mind and willingness to break things

Getting started

  • Start with Exercise 0 to set up your environment
  • Work through exercises 0 and 1 in order (setup + first build)
  • After that, each section is self-contained — pick what interests you