Dear all, I'm trying to find the callgraph of a method, using the following code:
package main import ( "log" "golang.org/x/tools/go/callgraph" "golang.org/x/tools/go/packages" "golang.org/x/tools/go/ssa/ssautil" ) func main() { cfg := &packages.Config{Mode: packages.LoadSyntax} initial, err := packages.Load(cfg, "seehuhn.de/go/pdf") if err != nil { log.Fatal(err) } else if packages.PrintErrors(initial) > 0 { log.Fatalf("packages contain errors") } prog, pkgs := ssautil.Packages(initial, 0) if len(pkgs) != 1 { log.Fatalf("expected 1 package, got %d", len(pkgs)) } pkg := pkgs[0] pkg.Build() reader := pkg.Members["Reader"] f := prog.LookupMethod(reader.Type(), pkg.Pkg, "readXRef") g := callgraph.New(f) _ = g } (Also on the playgound at https://go.dev/play/p/_S-oKAJ6YNO, but resulting in some fancy error messages there.) This fails with the following error message: panic: seehuhn.de/go/pdf.Reader has no method seehuhn.de/go/pdf.readXRef What am I doing wrong? All the best, Jochen -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/68b8c937-7bce-44d4-81fb-2507b55fb0bcn%40googlegroups.com.