# some code end end Zombie.new.send(%w(undead method).join('_')) Can't just check for calls to the exact name 'undead_method' Static Analysis in Go 5 of 29
can find unreachable code, amongst other things. Audience participation: in Go, what do you look for to determine unreachable? Static Analysis in Go 9 of 29
looking for dead code. // If d.reachable is false on entry, stmt itself is dead. // When findDead returns, d.reachable tells whether the // statement following stmt is reachable. func (d *deadState) findDead(stmt ast.Stmt) { // ...elided... case *ast.ExprStmt: // Call to panic? call, ok := x.X.(*ast.CallExpr) if ok { name, ok := call.Fun.(*ast.Ident) if ok && name.Name == "panic" && name.Obj == nil { d.reachable = false } } Static Analysis in Go 23 of 29
result := make(chan int) go func() { result <- func() int { c += 1 return c }() }() return result } func main() { println(<-a(2)) } Static Analysis in Go 25 of 29
names find identifiers more than 20 characters long insert logging of "Now running FuncName" before each function find functions FuncName without a corresponding TestFuncName function Static Analysis in Go 28 of 29