The Go equivalent of Rustlings. Fix broken code, learn by failing, and become fluent in Go syntax and idioms through hands-on exercises.
Gopherlings is a terminal-based CLI tool that guides you through broken Go code and challenges you to fix it.
You donβt run a web app. You donβt follow instructions in a browser. You:
- Edit real Go files in your own editor
- Watch tests fail (and then pass)
- See real compiler errors and fix them
- Learn Go the way itβs written: from the bottom up
git clone https://github.com/cloudwalksolutions/gopherlings
cd gopherlings
go run cmd/root.go runThatβs it. Gopherlings will load your current lesson and watch your edits in real time.
- Test-first mindset: Every lesson starts with failing tests
- Hot reload: Your code is tested as you typeβlike a REPL, but meaningful
- You own your flow: Use your editor, your way
- Go idioms, not just syntax: We teach the βwhyβ as much as the βwhatβ
- No scaffolding BS: Just clone and go
cmd/ CLI entrypoints (gopherlings, scaffold)
src/ Scaffolding + internal logic
templates/ Templates for new lesson generation
lessons/ Where real code lives
lesson-plan.yaml Minimal lesson manifest
proverbs.yaml Canonical Go Proverbs
Each lesson is a broken Go program in a folder:
lessons/01_variables/
ββ main.go
ββ main_test.go
ββ README.md
ββ .config.json
You fix the code. Gopherlings tests it. When it passes, you move on.
go run cmd/gopherlings/main.go run # Run current lesson with hot reload TUI
go run cmd/gopherlings/main.go list # Show all available lessons
go run cmd/gopherlings/main.go doctor # Verify environment and dependencies
go run cmd/gopherlings/main.go generate # AI-powered lesson creationπ Hot reload is enabled by default π Tests are run on every save
Gopherlings now includes AI-powered lesson generation! Create custom lessons on-demand:
go run cmd/gopherlings/main.go generateThe tool will:
- Prompt you to describe the Go concept you want to learn
- Generate a complete lesson with broken code, tests, and documentation
- Create lesson files ready for immediate use
Example interaction:
$ go run cmd/gopherlings/main.go generate
What lesson would you like to create? Describe the Go concept or topic: interfaces and polymorphism
Generating lesson about: interfaces and polymorphism
Generated lesson:
ID: 25_interfaces_polymorphism
Title: Go Interfaces and Polymorphism
Description: Learn how to use interfaces to achieve polymorphism in Go...
Accept this lesson? (y/n): y
Lesson accepted! Writing to lessons directory...
Successfully wrote lesson files to lessons/25_interfaces_polymorphism
Powered by:
- Google Gemini (production) for high-quality lesson generation
- Local Ollama (development) for offline/testing scenarios
- Smart prompting that incorporates your specific learning goals
make cov # Run tests with coverage
make lint # Run golangci-lint on all source code
make fmt # Format all Go code
make run # Run the CLI toolWe welcome PRs! See CONTRIBUTORS.md to learn how to:
- Add new lessons
- Write idiomatic templates
- Keep the spirit of Go and the Go Proverbs
Inspired by Rustlings, but written for people who want to think in Go.