title: Use ast to get all function calls in a function
body: <p>I'm trying to list all function call in a function using ast. But having trouble understanding how it is suppose to be used. I have been able to get this far.</p>
  
  <pre><code>set := token.NewFileSet()
  packs, err := parser.ParseFile(set, serviceFile, nil, 0)
  if err != nil {
      fmt.Println("Failed to parse package:", err)
      os.Exit(1)
  }
  
  funcs := []*ast.FuncDecl{}
  for _, d := range packs.Decls {
      if fn, isFn := d.(*ast.FuncDecl); isFn {
          funcs = append(funcs, fn)
      }
  }
  </code></pre>
  
  <p>I have inspected funcs. I get to <code>funcs[n1].Body.List[n2]</code>.
  But after this i don't understand how i'm suppose to read the underlaying <code>data.X.Fun.data.Sel.name</code> (got it from evaluation in gogland) to get name of the function being called. </p>