From 30edda9d8d1b543976b8c75c86f8504496e6c5b3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 25 May 2023 19:58:14 +0200 Subject: newFunctionState: Return value instead of pointer Makes more sense to me to show the `&`s when we pass the value as an argument to functions. That makes it clearer that the functions are taking a reference type. --- defererr.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/defererr.go b/defererr.go index c835131..4ff0802 100644 --- a/defererr.go +++ b/defererr.go @@ -33,8 +33,8 @@ type functionState struct { deferErrorVar *ast.Ident } -func newFunctionState() *functionState { - return &functionState{ +func newFunctionState() functionState { + return functionState{ firstErrorDeferEndPos: -1, } } @@ -103,7 +103,7 @@ func checkFunctions(pass *analysis.Pass, node ast.Node) { pass, funcDecl.Body, errorReturnField, - fState, + &fState, ) // Stop if the `defer` closure does not assign to an error @@ -112,7 +112,12 @@ func checkFunctions(pass *analysis.Pass, node ast.Node) { return true } - checkFunctionReturns(pass, funcDecl.Body, errorReturnIndex, fState) + checkFunctionReturns( + pass, + funcDecl.Body, + errorReturnIndex, + &fState, + ) return true }, -- cgit v1.2.3