~/talk

Writing a Static Analyzer for Go Code

Talkat GopherCon 2021 · 2021-12-05..12-08· [go, testing]
slides:none on file

Builds a static analyzer that finds missing closes, double closes and missing error handling by matching short variable declarations that yield an io.Closer and an error, walking the AST with the inspector and withStack, using types.Info to check interfaces, scanning subsequent statements for calls to Close and for an if that references the error, counting closes and reporting failures with pass.Reportf; packaged as a singlechecker CLI and successfully flags real violations in real packages.

AI-written summary · about

  1. 0:00Introduction
  2. 8:23Writing a static analysis tool
  3. 13:55Run method
  4. 16:43Check for assignment statement
  5. 18:13Iterating over assignment statement
  6. 19:51Defining closer and error types
  7. 22:51Checking for close
  8. 24:46Improving close
  9. 25:16Handling defer
  10. 25:49Handling errors
  11. 27:16Close function
  12. 29:32Single checker
  13. 30:47Conclusion
~/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.