~/talk

Defer

Talkat GoWayFest 4.0 (online edition) · 2020-07-11..07-12· [go]
name:Mat Ryer
github:matryer
slides:none on file

Go’s defer calls run in LIFO, are useful for closing files and HTTP response bodies, unlocking mutexes, and test cleanup, and appear 418 times in the Pace codebase (418 defers, ~69/month). Common gotcha: loop variable capture makes every deferred closure see the final value unless you pass the loop value into the closure. Under the hood each defer allocates a linked-list node; Go 1.14 open-coded up to 8 defers reduces overhead from ~35ns to ~4ns (naked call ~3ns).

AI-written summary · about

  1. 0:00Intro
  2. 5:34Use Cases
  3. 14:30Conditions
  4. 19:13Fact of the Day
  5. 23:23Defer
  6. 26:18Defer Performance
  7. 28:22Open Coding
  8. 29:40Open Defer
  9. 33:00Conclusion QA
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.