From 00707a7693c67076898556f2f5de2c8db46a0463 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 25 May 2023 21:25:52 +0200 Subject: Add more detail to the explanation of how the analyser works --- defererr.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'defererr.go') diff --git a/defererr.go b/defererr.go index 498708c..226e52b 100644 --- a/defererr.go +++ b/defererr.go @@ -16,10 +16,11 @@ var Analyzer = &analysis.Analyzer{ } func run(pass *analysis.Pass) (interface{}, error) { - // TODO: Find defer closure - // Does it set error defined in outer scope? - // Does outer scope declare error variable in signature? - // Is err variable returned after closure? + // Look at each function and check if it returns an error. + // If so, look for a defer inside the function. + // If a captured error variable is defined in the defer's closure, ensure + // that the variable is declared in the function's signature, and that any + // returns after the defer closure use the assigned error variable. for _, file := range pass.Files { checkFunctions(pass, file) -- cgit v1.2.3