Home
/ Golang Engineering
/ Basic Data in Memory BasicTopic 6 lessons ~5h
Lessons, in order 01
Arrays and Slices An array is a fixed-size block of elements, laid out one after another; its length is part of its type and assigning it copies every element. A slice is a three-word header — pointer, …
Beginner
55 min
02
Strings, Bytes and Runes A Go string is a two-word header — pointer and length — over a run of bytes that never change. It is not an array of characters. By convention those bytes are UTF-8, in which one character …
Beginner
45 min
03
Maps A map is a hash table: it hashes the key to a number, uses that number to pick a place in an array, and stores the key and value there. A map value in Go is a single pointer to a runtime …
Intermediate
50 min
04
Pointers and Struct Layout A pointer is the memory address of a variable: eight bytes that say where something lives. Go pointers are safe — no arithmetic, never dangling, checked for nil — but they still decide what …
Intermediate
50 min
05
Interfaces Under the Hood An interface value is two words: one identifies the concrete type stored inside (and, for interfaces with methods, a table of that type's methods), the other is a pointer to the data. …
Intermediate
50 min
06
Generics and Iterators Generics let a function or type take a type parameter: func MaxT cmp.Ordered T works for every ordered type, checked at compile time, with no any and no type assertions. A constraint — an …
Intermediate
50 min
About this topic Topic I said slices, strings, maps and interfaces are “small headers that point elsewhere”.
This topic draws each header, byte by byte, and shows what follows from the drawing.
When you finish you can draw any Go value as boxes and arrows, say how many bytes it
occupies, and predict whether an operation copies, shares or allocates.