Personal workspace for learning Go, framed for someone coming from Python.
Each exercise is a standalone, runnable Go file. From the repo root:
go run crashCourse/01_intro/01_hello.go
go run crashCourse/02_types/01_variables.go
go run patterns/01_functionalOptions/01_functional_options.go
# ...etc
Every exercise file carries a //go:build ignore tag. That tag tells the Go
toolchain "this file is a standalone script, not part of a package build", which
lets multiple package main files coexist in the same folder without colliding
on func main(). Without it, go build ./... and the LSP would complain about
"main redeclared". You can ignore that tag for now — just know that's why it's
there.
Work through the folders in this order. Each one builds on the previous.
-
crashCourse/01_intro/— Smoke test. The classic Hello World, just to confirm yourgotoolchain works. -
crashCourse/02_types/— Variables, zero values, the two declaration styles (varvs:=), constants, explicit type conversion, and functions (multiple return values, variadics, first-class functions). The biggest mental shift from Python: static types and zero values instead ofNone. -
crashCourse/03_slicesAndMaps/— Slices (Python'slist, but typed and backed by an array) and maps (Python'sdict, but typed). Key gotchas: slice-mutation aliasing through the backing array, the two-value map lookup (val, ok := m[key]), and why writing to a nil map panics. -
crashCourse/04_structs/— Structs, methods, value vs pointer receivers, and embedding (composition over inheritance). Then pointers explicitly:&and*, why you'd use a pointer, and how Go avoids the C footguns. -
crashCourse/05_interfaces/— Implicit interface satisfaction (Go's take on duck typing),Stringer, type assertions, and type switches. This is how you write testable Go: define an interface, swap a real DB for a fake. -
crashCourse/06_errors/— Errors as values, not exceptions.errorinterface, sentinel errors,fmt.Errorf("...: %w", err)wrapping, anderrors.Is/errors.As. Also covers whypanic/recoveris NOT for normal error handling. -
crashCourse/07_concurrency/— Goroutines, channels,sync.WaitGroup,select, worker pools — and thencontext.Contextfor cancellation and timeouts. The mental model is very different fromasyncio: there's noasync/await, every goroutine is preemptible, and you communicate by passing values through channels. -
crashCourse/08_toolchain/—defer(LIFO ordering, immediate argument evaluation,recover) and packageinit()functions. The Go equivalents ofwith/finallyand module-level setup. -
crashCourse/09_testing/— The built-intestingpackage, table-driven tests, subtests witht.Run, and benchmarks. No pytest needed — the toolchain has it all. Run withgo test ./crashCourse/09_testing/.
Start this after you can write error-handling, interfaces, and basic goroutines without looking them up. These exercises cover design and implementation patterns that show up constantly in real Go production code.
| # | Folder | Pattern |
|---|---|---|
| 1 | 01_functionalOptions/ |
Functional options constructor (WithXxx functions) |
| 2 | 02_errorWrapping/ |
Sentinel hierarchies, multi-error, deep chain walking |
| 3 | 03_contextPropagation/ |
Threading context through real call chains |
| 4 | 04_interfaceDI/ |
Dependency injection via interfaces, swappable fakes |
| 5 | 05_workerPool/ |
Fan-out/fan-in pipeline with backpressure and shutdown |
| 6 | 06_gracefulShutdown/ |
OS signal handling + context cancellation for servers |
| 7 | 07_syncPatterns/ |
sync.Once, sync.Pool, sync.Map — when and why |
| 8 | 08_generics/ |
Type-safe containers and helpers (Go 1.18+ generics) |
See patterns/README.md for the full description and prerequisites.
crashCourse/README.md— quick-reference command table for the crash course.patterns/README.md— pattern list, prerequisites, and recommended order for the intermediate material.