aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gocapturedrefrace.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go
index d88989e..483bd7f 100644
--- a/gocapturedrefrace.go
+++ b/gocapturedrefrace.go
@@ -6,6 +6,7 @@ import (
"go/ast"
"go/printer"
"go/token"
+ "go/types"
"golang.org/x/tools/go/analysis"
)
@@ -166,6 +167,19 @@ func assignmentsInFunc(
fmt.Println("ASSIGN:", ident)
}
+ obj := pass.TypesInfo.ObjectOf(ident)
+ if obj != nil {
+ fmt.Printf("obj: %#v\n", obj)
+
+ theVar, ok := obj.(*types.Var)
+ if !ok {
+ return true
+ }
+
+ fmt.Printf("obj origin: %#v\n", theVar.Origin())
+ fmt.Printf("obj parent: %#v\n", theVar.Parent())
+ }
+
assignments = append(assignments, ident.Name)
return true