Build production static analyzers on the Go team's analysis framework. From AST walk to go vet plugin.
// A minimal analyzer the course builds in module 2 var Analyzer = &analysis.Analyzer{ Name: "nilcheck", Doc: "reports guaranteed nil derefs", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, } func run(pass *analysis.Pass) (any, error) { insp := pass.ResultOf[inspect.Analyzer] insp.Preorder(nodes, func(n ast.Node) { pass.Reportf(n.Pos(), "nil deref") }) return nil, nil }
The full "Building nilcheck from an empty file" lesson, source included.