Static Analysis in Go
summary
Step‑by‑step walkthrough of how to tokenise, parse and type‑check Go source to find actual occurrences of a type named "gopher" (demo finds it three times), using go/token, go/ast with ast.Inspect and go/types via a pass/File→token.FileSet→types.Info flow; shows how that data powers two real projects: go‑httpdoc (generate API docs from HTTP tests) and a reflection helper (gpass) that accesses nested struct fields by Go expressions. Concrete code snippets and error handling included.
AI-written summary · about
chapters (23)
- 0:00Intro
- 1:38Tech Commnities
- 2:54Where's Gopher?
- 4:29Static Analysis & Dynamic Analysis
- 5:20Reflection → Reflection
- 5:59Static Analysis Tools for Go → There are many static analysis tools for Go
- 7:13Go for Static Analysis → Go is easy to static analyze
- 7:47Sub packages of go package
- 8:14Flow of Static Analysis
- 11:14Parsing -go/parser,go/ast → Converting tokens to abstract syntax tree
- 12:46AST of "Hello, World"
- 17:08Getting AST from a file
- 18:56token. FileSet
- 24:43Traversing AST - Recursively
- 25:14Inspect identifiers
- 27:28Type Checking (types.Config).Check do a type checking
- 28:49types. Info holds results of type checking
- 29:26Inspect Gopher type
- 33:04Tests for requests and responses
- 35:53Create own static analysis tools
- 36:46Banner Tool → A management tool of in-app banners
- 37:49Evaluation of Delivery Conditions → Describing delivery conditions by a Go like expression
- 39:10Conclutions → Static Analysis is EASY in Go








