Reflection and internals
A program can read its own types at run time, and it pays for that. These lessons cover reflect and struct tags, the reflection inside encoding/json, the memory model, escape analysis, the garbage collector, the metrics the runtime exposes and the directives the compiler reads. They explain why the choices of the earlier parts behave the way they do.
105
reflection: types and values
reflect.TypeOf and ValueOf, Kind against Type, a field read by name and the panic of a wrong kind
Open
106
Struct tags
a tag on a field, reflect.StructTag.Get, a tag read by a library and the syntax the compiler checks
Open
107
How encoding/json uses reflection
the field walk, the tag names, the cached type information and what a custom Marshaler changes
Open
108
The Go memory model
happens-before, a channel that publishes a write, a mutex that orders and the race the model forbids
Open
109
Escape analysis and allocations
-gcflags=-m, a value that stays on the stack, one that escapes and the allocations a profile shows
Open
110
The garbage collector
the concurrent collector, GOGC, GOMEMLIMIT, a finalizer and the pause a program sees
Open
111
Runtime metrics and traces
runtime/metrics, runtime.ReadMemStats, a trace with go tool trace and the numbers worth watching
Open
112
Compiler directives and intrinsics
//go:noinline, //go:nosplit, //go:linkname and the directives a program should not need
Open