diff options
author | Teddy Wing | 2023-05-25 19:58:14 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-25 19:58:14 +0200 |
commit | 30edda9d8d1b543976b8c75c86f8504496e6c5b3 (patch) | |
tree | 798e6c2ac7eec6aafebe00e36f7707a9cc325c94 | |
parent | 30bf101a9f8e8a2dbc2f2be34e2ef06464036b08 (diff) | |
download | godefererr-30edda9d8d1b543976b8c75c86f8504496e6c5b3.tar.bz2 |
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.
-rw-r--r-- | defererr.go | 13 |
1 files 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 }, |