🐹 Learn Go — From Zero to Principal

A deep-dive, code-first engineering reference. Every chapter is structured around annotated production code, anti-patterns with fixes, edge cases, and gotchas — not prose tutorials.

How to Use This Course

  1. Read sequentially for a structured path (01 → 28).
  2. Jump to a chapter as a reference when you hit a concept in production.
  3. Run the code — every snippet is self-contained and runnable.
  4. Run the quizzes at the end of each chapter to test understanding.
  5. Do the capstone exercises in chapter 28.

Prerequisites

  • Go 1.22+ installed (go version).
  • A code editor (VS Code + the Go extension recommended).
  • Comfort with at least one other programming language.
  • Understanding of basic concurrency concepts (threads, locks, queues).

Curriculum

Part I — Foundations & Toolchain

#TopicWhy It Matters
01Introduction & SetupToolchain internals, module graph (MVS), build tags, cross-compilation, embed, cgo, race detector, Docker.
02Package Anatomy & go CommandCompilation pipeline, init() ordering, go subcommands, test cache, os.Args/flag/cobra.
03Variables, Constants & TypesZero-value memory layout, untyped constant precision, iota bit flags, named types, shadowing trap.
04Basic Types & ConversionsInteger overflow, IEEE 754 float traps, UTF-8 string internals, []byte↔string allocation cost.
05FunctionsMultiple returns, closure capture semantics, defer execution model, variadic options pattern.
06Control Flowif-init scoping, range internals, switch dispatch, labeled breaks, Go 1.22 loop scoping fix.

Part II — Data Structures & Memory

#TopicWhy It Matters
07Arrays, Slices & StringsSlice header memory layout, append growth strategy, aliasing traps, slices package, zero-allocation strings.
08MapsHash map bucket layout, the non-addressable value trap, concurrent map fatal error, ordered map impl.
09StructsField alignment/padding, embedding composition, struct tags, zero-value-is-useful idiom, struct{} sets.
10PointersEscape analysis (stack vs heap), value vs pointer method sets, nil receiver safety, when pointers hurt.
11Methods & ReceiversValue vs pointer semantics, consistency rule, nil receiver methods, method promotion, builder pattern.
12InterfacesInterface internals (type, value), the nil interface trap, consumer-side definition, accept-interfaces-return-structs.
13Type Assertions & SwitchesComma-ok assertions, type switch dispatch, interface-to-interface capability checks, JSON float64 trap.
14GenericsType parameters, ~T underlying-type matching, cmp.Ordered, slices/maps packages, generic type design.

Part III — Error Handling & Concurrency

#TopicWhy It Matters
15Error HandlingError wrapping chains, errors.Is/As, sentinel vs typed errors, nil-interface trap, errors.Join, panic-vs-error.
16GoroutinesG-M-P scheduling model, stack growth, GOMAXPROCS, leak prevention, unbounded fan-out, preemption.
17ChannelsChannel semantics table, close rules, directional channels, nil channel patterns, chan struct{} signals.
18Select & Multiplexingtime.After leak, fan-in/fan-out, priority selects, for-select loops, nil-channel state machines.
19sync PackageMutex/RWMutex internals, WaitGroup race-free usage, Once lazy init, Cond, Pool allocation reuse, Map.
20ContextCancellation trees, deadlines, the cancel leak, request-scoped values, errgroup bounded concurrency.

Part IV — I/O, Standard Library & Production Engineering

#TopicWhy It Matters
21Packages & ModulesModule versioning (v2+ paths), internal/ enforcement, workspaces, replace directives, private modules, go.sum.
22I/O, Files & io Packageio.Reader/Writer composition, io.Copy, bufio.Scanner, file durability (Sync/Close), io.Pipe.
23Encoding: JSON, CSV, gobStruct tags, omitempty traps, streaming JSON, json.Number precision, custom marshalers, gob.
24Time & DatesMonotonic vs wall clock, reference time format, == vs Equal, time zones, tickers/timers.
25Testing & BenchmarkingTable-driven tests, t.Parallel, benchmark allocation analysis, fuzzing, httptest, coverage gating.
26Concurrency PatternsWorker pool, pipeline, fan-out/fan-in, errgroup, semaphore, generator, graceful shutdown.
27Profiling & Performancepprof CPU/heap/goroutine, escape analysis, allocation reduction, strings.Builder, sync.Pool, inlining.
28Exercises & Project IdeasFrom beginner to expert: generics, concurrency patterns, concurrent web crawler, graceful server, capstone task queue.

Learning Path Suggestions

If you're coming from Python/Ruby/JS

Go's static typing, explicit error handling, and value semantics are the big shifts. Read 03–05 (types, functions), 07 (slices — they're not Python lists), 15 (errors — no exceptions), and 16–20 (concurrency — goroutines/channels are unique to Go).

If you're coming from C/C++/Rust

Go is simpler but has surprises: garbage collection (no manual memory management), goroutines (not OS threads), channels (not mutexes as default), and implicit interfaces. Read 10 (escape analysis), 12 (interfaces), 16–18 (concurrency), 27 (profiling — escape analysis is Go's answer to zero-cost abstractions).

If you're a senior engineer

Start with 01 (toolchain internals), 10 (escape analysis), 12 (interface nil trap), 15 (error wrapping chains), 16 (G-M-P scheduler), 20 (context cancellation trees), 26 (concurrency patterns), 27 (profiling). The exercises in 28 are production-graded.

What Makes This Course Different

  • Code-first: every concept is demonstrated with production-grade annotated code, not prose.
  • Anti-patterns → fixes: every chapter shows the wrong way, explains the trap, and gives the correct production pattern.
  • Edge cases and gotchas: each chapter includes subtle boundary conditions, compiler quirks, and runtime failure modes.
  • Quick quizzes: test understanding with tricky code snippets at the end of each chapter.
  • Production focus: Docker multi-stage builds, graceful shutdown, supply chain (go.sum), race detection, profiling — not just syntax.

Prerequisites for Chapters

ChaptersRequires
01–06Nothing (start here if new to Go)
07–1401–06 (foundations)
1505 (defer), 12 (nil interface)
16–2006 (control flow), 11 (methods)
21–2401 (modules), 04 (types)
25–27All prior chapters
28All chapters (capstone exercises)