From 4e2286969f94f2c4fe6f1850e9b7a96d7e8167f2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 15 May 2023 02:44:06 +0200 Subject: Try to limit identifier enumeration to variables This does ignore "strings" and "Repeat" in the "simple.go" test file. --- gocapturedrefrace.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go index 21a0d16..8f79d76 100644 --- a/gocapturedrefrace.go +++ b/gocapturedrefrace.go @@ -54,15 +54,19 @@ func checkClosure(pass *analysis.Pass, funcLit *ast.FuncLit) { ast.Inspect( funcLit, func(node ast.Node) bool { - variable, ok := node.(*ast.Ident) + ident, ok := node.(*ast.Ident) if !ok { return true } + if ident.Obj == nil { + return true + } + pass.Reportf( - variable.Pos(), + ident.Pos(), "variable found %q", - variable, + ident, ) return true -- cgit v1.2.3