From 184305b19644fcaf669ea12c90281090a492f01d Mon Sep 17 00:00:00 2001 From: Augusto Date: Fri, 20 Mar 2020 20:31:22 +0000 Subject: [PATCH] Adds a functions that given a scope returns the functions declared --- go/tests/rc/rc.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/go/tests/rc/rc.go b/go/tests/rc/rc.go index 2ae6397d8..9888d06ab 100644 --- a/go/tests/rc/rc.go +++ b/go/tests/rc/rc.go @@ -876,3 +876,16 @@ func (i *impVisitor) Visit(n ast.Node) ast.Visitor { } return i } + +func funcs(s *ast.Scope) []string { + scopeStr := s.String() + scp := strings.Split(scopeStr, "\n") + var funcs []string + for _, v := range scp { + nv := strings.TrimSpace(v) + if strings.HasPrefix(nv, "func ") { + funcs = append(funcs, strings.TrimPrefix(nv, "func ")) + } + } + return funcs +}