diff options
author | Teddy Wing | 2023-05-16 21:45:34 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-16 21:45:34 +0200 |
commit | 620d5bb8d1c671ebf2090ab2dc9f0c147e34e55e (patch) | |
tree | 4be4be5a53bd8096940f7f9db84dbe1c36aa76f0 | |
parent | ed560db307ce275577b058ed921c2722bacb2468 (diff) | |
download | gocapturedrefrace-620d5bb8d1c671ebf2090ab2dc9f0c147e34e55e.tar.bz2 |
checkClosure: Move `funcScope` inside this function
It's not used in `run()`, so we can move it here.
-rw-r--r-- | gocapturedrefrace.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go index 1a60cf5..cded016 100644 --- a/gocapturedrefrace.go +++ b/gocapturedrefrace.go @@ -45,10 +45,7 @@ func run(pass *analysis.Pass) (interface{}, error) { ) } - // Get the closure's scope. - funcScope := pass.TypesInfo.Scopes[funcLit.Type] - - checkClosure(pass, funcLit, funcScope) + checkClosure(pass, funcLit) return true }, @@ -60,11 +57,10 @@ func run(pass *analysis.Pass) (interface{}, error) { // checkClosure reports variables used in funcLit that are captured from an // outer scope. -func checkClosure( - pass *analysis.Pass, - funcLit *ast.FuncLit, - funcScope *types.Scope, -) { +func checkClosure(pass *analysis.Pass, funcLit *ast.FuncLit) { + // Get the closure's scope. + funcScope := pass.TypesInfo.Scopes[funcLit.Type] + ast.Inspect( funcLit, func(node ast.Node) bool { |