Data Structures & Types¶
How Go organizes data -- from built-in collections (slices, maps) through custom types (structs, interfaces) to advanced type features (generics, embedding). This section covers Go's approach to polymorphism and code reuse without classes or inheritance.
| # | Topic | What You'll Learn | Level |
|---|---|---|---|
| 1 | Arrays & Slices | Slice header (ptr, len, cap), append, shared arrays, pre-allocation |
Beginner |
| 2 | Maps | Hash maps, comma-ok idiom, nil vs empty, not concurrent-safe | Beginner |
| 3 | Structs | Fields, tags, constructors, anonymous structs, JSON mapping | Beginner |
| 4 | Interfaces & Polymorphism | Implicit satisfaction, empty interface, composition, nil trap | Intermediate |
| 5 | Methods & Receivers | Value vs pointer receivers, method sets, interface satisfaction | Intermediate |
| 6 | Embedding & Composition | Go's alternative to inheritance, promoted methods, shadowing | Intermediate |
| 7 | Type Assertions & Switches | Runtime type checking, safe assertions, extracting behavior | Intermediate |
| 8 | Generics | Type parameters, constraints, comparable, when to use generics |
Advanced |
Interview Quick Hits
- Slices are reference types backed by arrays -- understand the slice header struct
- Maps have random iteration order and are not safe for concurrent use
- Interfaces are satisfied implicitly -- no
implementskeyword - "Accept interfaces, return structs" is a key Go design proverb
- Method sets determine interface satisfaction: pointer receivers are NOT in the value method set