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.26.1 - we'll check out the specific release tag to ensure consistency across all exercises.
Prerequisites
- Basic knowledge of Go programming
- Familiarity with command line tools
- Git installed on your system
- Go compiler version 1.24 or newer (required for bootstrapping the build process)
- At least 4GB of free disk space
Workshop Overview
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:
Getting Started
- Start with Exercise 0 to set up your environment
- Work through the exercises in order
- After exercise 1, you can pick and choose the exercise that you want.
Tips for Success
- Take your time with each exercise - compiler internals are complex!
- Don't hesitate to explore the Go source code beyond what's required
- Use
gitto track your changes and revert when needed - Test your modifications thoroughly with various Go programs
Resources
Video References
These workshop exercises are based on insights from my talks:
Understanding the Go Compiler
Deep dive into Go's compilation process
Understanding the Go Runtime
Exploration of Go's runtime system
Workshop Completion
Upon completing all exercises, you'll have:
- Built Go from source and understood the bootstrap process
- Modified language syntax by changing scanner and parser behavior
- Customized development tools like gofmt and compiler optimizations
- Implemented SSA optimizations in the compiler backend
- Modified runtime behavior including program entry points and scheduler monitoring
- Altered concurrency algorithms like select statement randomization
- Customized error reporting with Java-style stack trace formatting
Congratulations! You'll have gained the confidence to keep exploring the Go source code. This knowledge enables you to:
- Start small contributions to the Go project
- Build custom language variants and tools
- Understand some trade-offs in language and runtime design
Contributing
Found an issue, have an improvement idea or want to add more exercises? Please open an issue or submit a pull request!