Code-Memo

Go runtime, compiler, and toolchain

Compiler

go build invokes compile, link, and optimization passes. SSA-based optimizer inlines and removes dead code.

Scheduler

G (goroutine), M (OS thread), P (logical processor): work stealing schedules G onto M with GOMAXPROCS Ps.

Garbage collector

Concurrent tri-color mark-and-sweep; write barriers track pointer changes during marking. Tuning env vars exist (GOGC default 100) but measure before changing.

Stack

Goroutine stacks start small and grow/shrink as needed (segmented/stack copying historically; continuous stacks in modern Go).

Assembly and unsafe

Rare for app code; unsafe.Pointer rules are strict — misuse breaks the type system.

Trace
go test -trace=trace.out
go tool trace trace.out

Shows goroutine scheduling and blocking.

Build modes
Modules cache

$GOMODCACHE stores downloaded modules; go clean -modcache clears it.

Compatibility

The Go 1 compatibility promise keeps old code building on newer toolchains; deprecated APIs linger with warnings in vet or release notes.