Pidoku

Archive

This learning material is in the archive. It is not currently maintained and has not been updated with the latest information, so tool versions, prices and dates may be out of date.

Golang

Go from the first program to the runtime — how values sit in memory, how the allocator, garbage collector and scheduler work, and how to build AI systems in it.

Start with Module 1
  • 6 modules
  • 37 lessons
  • ~33h 5m

Modules

Read them in order. Each module builds on the one before.

  1. Module 1 The Language Go is a small language. This module covers all of it that you need daily, quickly, and with one eye already on what each feature costs. 5 lessons · ~3h 45m
  2. Module 2 Data in Memory Module 1 said slices, strings, maps and interfaces are "small headers that point elsewhere". This module draws each header, byte by byte, and shows what follows from the drawing. 6 lessons · ~5h
  3. Module 3 Memory Go manages memory for you. This module explains exactly how, because the difference between a service that spends 2% of its CPU on memory management and one that spends 30% is almost always … 5 lessons · ~4h 45m
  4. Module 4 Concurrency Goroutines are why most people choose Go. This module explains what one actually is, how the runtime runs millions of them on a handful of threads, and how to write concurrent code that is … 6 lessons · ~5h 40m
  5. Module 5 Performance Modules 3 and IV explained what the runtime does. This module is about measuring a program, understanding what the compiler and the CPU did with it, and making it faster on purpose. 5 lessons · ~4h 40m
  6. Module 6 AI in Go Everything so far, applied. This module builds the core pieces of an AI system in Go using nothing but the standard library: the arithmetic, a network that learns, a tokenizer, a transformer … 9 lessons · ~9h 15m

Build

Reference

About

Learn Go the way a systems engineer needs it: what every value looks like in memory, what the allocator, garbage collector and scheduler do on your behalf, how to measure and speed up a program — and how to build neural networks, tokenizers, LLM clients and model servers in it.

Every other path in this library writes its code in Go. This is the path about Go itself. It starts at “what is a variable” and ends with a transformer forward pass and a batching model server, both written from nothing but the standard library.

It assumes you have programmed in some language. It does not assume you know Go, C, or how a garbage collector works.


How this learning material works#

Every lesson follows the same shape:

  1. The idea in one minute — the whole lesson in a few sentences.
  2. An analogy — something from everyday life with the same shape.
  3. A picture — a hand-drawn diagram, usually of memory.
  4. How it really works — the precise version, with real sizes and names.
  5. Code — a small Go program you can run. Nearly all of them measure the thing the lesson claims, so you never have to take the text’s word for it.
  6. Remember this — the three or four facts worth keeping.
  7. Try it and Check yourself — exercises and questions.

Why draw memory?#

Most Go surprises are memory surprises: a slice that changes behind your back, an interface that is “nil but not nil”, a goroutine that leaks, a program that spends a third of its time in the garbage collector. Each one stops being a surprise once you can draw the bytes.

flowchart TB
  SRC["Your code<br/>values, pointers, goroutines"] --> CMP["Compiler<br/>escape analysis, inlining"]
  CMP --> BIN["One static binary<br/>your code + the runtime"]
  subgraph RT["The Go runtime, inside your process"]
    SCH["Scheduler<br/>goroutines onto threads"]
    ALC["Allocator<br/>size classes, spans"]
    GC["Garbage collector<br/>concurrent mark and sweep"]
  end
  BIN --> RT
  RT --> OS["Operating system<br/>threads, memory pages, sockets"]
  class SRC neutral
  class CMP,BIN compute
  class SCH queue
  class ALC,GC memory
  class OS io

The path#

flowchart LR
  I["1 · The language"] --> II["2 · Data in memory"]
  II --> III["3 · Memory"]
  III --> IV["4 · Concurrency"]
  IV --> V["5 · Performance"]
  V --> VI["6 · AI in Go"]
  class I neutral
  class II,III memory
  class IV queue
  class V compute
  class VI io
ModuleYou will be able to
Module 1 · The LanguageRead and write idiomatic Go: values, functions, errors, structs, interfaces, packages, tests
Module 2 · Data in MemoryDraw a slice, string, map, struct and interface as bytes, and predict what a copy shares
Module 3 · MemoryExplain stack vs heap, read escape analysis, describe the allocator and the garbage collector, and cut allocations
Module 4 · ConcurrencyExplain the scheduler, use channels, context and sync correctly, and reason about data races
Module 5 · PerformanceBenchmark and profile, read what the compiler did, lay out data for the cache, and know what cgo and SIMD cost
Module 6 · AI in GoBuild tensors, a trained neural network, a tokenizer, a transformer forward pass, an LLM client, vector search and a batching model server
ProjectsBuild six programs that make the ideas stick

What you need#

  • Go 1.22 or newer. Every runnable program in this learning material builds with it. Lessons mark the few features that need a newer release and show them as snippets.
  • A terminal. No other tools, no GPU, no Python.

Getting started in fifteen minutes#

  1. Install Go from go.dev/dl and run go version.
  2. Read 1.a and run its program with go run.
  3. If you already write Go, start at 2.a — module 2 is where the pictures begin — or go straight to 3.b Escape analysis.
  4. If you came for the AI part, read 6.a first; it says which earlier lessons each AI lesson leans on.

A note on versions#

Go releases every six months and keeps a strict compatibility promise: code written for Go 1.0 still compiles. The language changes slowly; the runtime improves constantly. On 3 October 2026, when this learning material was last checked, the current release was Go 1.27 (August 2026). What recent releases changed, in the order this learning material meets them:

ReleaseWhat changedLesson
1.22 (Feb 2024)Each loop iteration gets its own variable; range over an integer1.c
1.23 (Aug 2024)Range over functions (iterators)2.f
1.24 (Feb 2025)Maps rebuilt as Swiss tables; testing.B.Loop; weak pointers2.c, 5.a
1.25 (Aug 2025)GOMAXPROCS respects container CPU limits; testing/synctest; sync.WaitGroup.Go4.a, 4.d
1.26 (Feb 2026)“Green Tea” garbage collector on by default; new(expr); cheaper cgo calls3.d, 5.d
1.27 (Aug 2026)Generic methods; encoding/json/v2; faster small allocations; goroutine-leak profile2.f, 3.c, 4.f

Runtime internals — sizes, thresholds, algorithms — are implementation details and do change. Wherever this learning material quotes one, the program beside it measures it on your machine.

Sister paths#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in