aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-05-20 14:35:37 +0200
committerTeddy Wing2023-05-20 14:35:37 +0200
commit68571cceeb663340bc196a6f01e022713a1eb233 (patch)
treeb45e4ba7dbd4be629627d6a5bdbd5483276e48f6
parent266552a2e1b202b2aadb7b6105e07afdd681ef5c (diff)
downloadgocapturedrefrace-68571cceeb663340bc196a6f01e022713a1eb233.tar.bz2
Ideas for getting a FuncLit from an `*ast.Ident` variable
-rw-r--r--capturedrefrace.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/capturedrefrace.go b/capturedrefrace.go
index 54c5c04..3d7dd3a 100644
--- a/capturedrefrace.go
+++ b/capturedrefrace.go
@@ -144,6 +144,19 @@ func run(pass *analysis.Pass) (interface{}, error) {
return nil, nil
}
+func funcLitFromIdent(ident *ast.Ident) *ast.FuncLit {
+ assignStmt, ok := funcIdent.Obj.Decl.(*ast.AssignStmt)
+ if ok {
+ // TODO: Get assignStmt.Rhs[position of ident name in assignStmt.Lhs]
+ for _, expr := range assignStmt.Rhs {
+ fl, ok := expr.(*ast.FuncLit)
+ if ok {
+ fmt.Printf("funclit: %#v\n", fl)
+ }
+ }
+ }
+}
+
// checkClosure reports variables used in funcLit that are captured from an
// outer scope.
func checkClosure(pass *analysis.Pass, funcLit *ast.FuncLit) {