I'm trying to extract the documentation for various functions an methods using the go/doc package. The code looks pretty much as below. The issue is that it prints/provides only the functions from the package(exported and unexported) but no method regardless if they're exported or unexported. I also tried AllMethods
mode with no success. Is this a bug or I'm missing something?
pkg := doc.New(mainPkg, "./", doc.AllDecls)
for _, vv := range pkg.Funcs {
log.Infof("vv.Name %v, vv.Recv %v", vv.Name, vv.Recv, )
}
Iterate through pkg.Types
and on each item you can get its Methods.
type Type struct {
Doc string
Name string
Decl *ast.GenDecl
// associated declarations
Consts []*Value // sorted list of constants of (mostly) this type
Vars []*Value // sorted list of variables of (mostly) this type
Funcs []*Func // sorted list of functions returning this type
Methods []*Func // sorted list of methods (including embedded ones) of this type
}