Browse Source

Adds a functions that given a scope returns the functions declared

pull/646/head
Augusto 5 years ago committed by xpetit
parent
commit
184305b196
  1. 13
      go/tests/rc/rc.go

13
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
}

Loading…
Cancel
Save