What's The Point? A Guide To Using Pointers Without Panicking
summary
Practical guide that demos actual Go behavior: slice copies share an underlying array and append can be nondeterministic depending on capacity, maps and slices are reference objects and a nil map panics on write, methods on nil pointer receivers sometimes work but accessing fields panics. Benchmarks show pointer vs value: ~260× speedup for 8KB and ~180,000× for 8MB (80 bytes ≈ 1.4×). Advice: weigh size, nilability, mutability; use copy, validate inputs, and sync for concurrent writes.
AI-written summary · about
chapters (15)
- 0:00Introduction and background
- 3:20Pointers basics recap
- 4:20Interactive pointer quiz
- 7:25Slices as reference objects
- 10:00Append behavior with slices
- 14:50Maps and reference objects
- 16:50Pointer vs value decision criteria
- 19:00Performance considerations
- 21:30Nil ability in error handling
- 23:15Validating incoming data
- 26:45Mutability and access control
- 30:35Pointer vs value receivers
- 32:55Interfaces and receivers
- 33:55Concurrency and shared state
- 35:45Summary and trade-offs
related talks
33mFun With Pointers
19mGo - Best practices
30mMemory Management in Go: The good, the bad and the ugly
53mThe Strengths of the `weak` Package: Weak Pointers Arrive in Go
25mThings in Go I Never Use
29mDissecting Slices, Maps and Channels in Go
14mOptimizing Go code without a blindfold
01h 02mKeeping it Simple With Go
