var doc … var Analyzer … const debug … var contextPackage … // checkLostCancel reports a failure to the call the cancel function // returned by context.WithCancel, either because the variable was // assigned to the blank identifier, or because there exists a // control-flow path from the call to a return statement and that path // does not "use" the cancel function. Any reference to the variable // counts as a use, even within a nested function literal. // If the variable's scope is larger than the function // containing the assignment, we assume that other uses exist. // // checkLostCancel analyzes a single named or literal function. func run(pass *analysis.Pass) (interface{ … } func runFunc(pass *analysis.Pass, node ast.Node) { … } func isCall(n ast.Node) bool { … } // isContextWithCancel reports whether n is one of the qualified identifiers // context.With{Cancel,Timeout,Deadline}. func isContextWithCancel(info *types.Info, n ast.Node) bool { … } // lostCancelPath finds a path through the CFG, from stmt (which defines // the 'cancel' variable v) to a return statement, that doesn't "use" v. // If it finds one, it returns the return statement (which may be synthetic). // sig is the function's type, if known. func lostCancelPath(pass *analysis.Pass, g *cfg.CFG, v *types.Var, stmt ast.Node, sig *types.Signature) *ast.ReturnStmt { … } func tupleContains(tuple *types.Tuple, v *types.Var) bool { … }