aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-05-15 02:44:06 +0200
committerTeddy Wing2023-05-15 02:44:06 +0200
commit4e2286969f94f2c4fe6f1850e9b7a96d7e8167f2 (patch)
treeac9580dfe1b4a6e306ab49a3dfb124bf79b5f987
parente708cee1ff72ee6a4a4886b9bea631d5ca71e710 (diff)
downloadgocapturedrefrace-4e2286969f94f2c4fe6f1850e9b7a96d7e8167f2.tar.bz2
Try to limit identifier enumeration to variables
This does ignore "strings" and "Repeat" in the "simple.go" test file.
-rw-r--r--gocapturedrefrace.go10
1 files 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