Welcome to an interactive workshop where you'll learn how to modify and experiment with the Go programming language source code! This hands-on workshop will guide you through understanding, building, and making changes to the Go compiler and runtime. π―
π This workshop uses Go version 1.25.1 - we'll check out the specific release tag to ensure consistency across all exercises.
This workshop consists of 11 exercises that will take you through the process from building Go from source, and making modifications at different places in the compiler, tooling and runtime. You'll gain some insights about the Go internals, from things like the lexer or parser, to runtime behaviors:
Get started by cloning and setting up the Go source code environment.
Learn to build the Go toolchain from source without any modifications.
Learn scanner/lexer modification by adding "=>" as an alternative syntax for starting goroutines.
Learn parser modification by enabling multiple consecutive "go" keywords (go go go myFunction).
Explore the inliner behavior by modifying function inlining parameters.
Learn about Go's tools by modifying gofmt to modify "hello" to "helo" in code.
Create a custom SSA compiler pass that detects division operations by powers of two that could be optimized to bit shifts.
Modify the Go runtime to wait for all goroutines to complete before program termination.
Add logging to the Go scheduler to monitor goroutines going to sleep.
Modify Go's select statement implementation to be deterministic instead of random.
Transform Go's verbose stack traces into Java-style formatting.
git
to track your changes and revert when neededThese workshop exercises are based on insights from my talks:
Deep dive into Go's compilation process
Exploration of Go's runtime system
Upon completing all exercises, you'll have:
Congratulations! You'll have gained the confidence to keep exploring the Go source code. This knowledge enables you to:
Found an issue, have an improvement idea or want to add more exercises? Please open an issue or submit a pull request!