I am trying to list the entire function call in a function using ast. But not understanding how it should be used. I could go that far.
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)
}
}
I checked the funky. I get to funcs[n1].Body.List[n2]. But after that, I don’t understand how I should read the litter data.X.Fun.data.Sel.name(obtained from the assessment in the hogland) to get the name of the function being called.
source
share