With some playing, I get to this, which gives me what I want for downstream.
func DocComments(path string) (docs map[string]map[string][]*ast.Comment, err error) { fset := token.NewFileSet() pkgs, err := parser.ParseDir(fset, path, nil, parser.ParseComments) if err != nil { return nil, err } docs = make(map[string]map[string][]*ast.Comment) for _, p := range pkgs { for _, f := range p.Files { for _, n := range f.Decls { fn, ok := n.(*ast.FuncDecl) if !ok || fn.Doc == nil { continue } var typ string if fn.Recv != nil && len(fn.Recv.List) > 0 { id, ok := fn.Recv.List[0].Type.(*ast.Ident) if ok { typ = id.Name } } doc, ok := docs[typ] if !ok { doc = make(map[string][]*ast.Comment) docs[typ] = doc } doc[fn.Name.String()] = fn.Doc.List } } } return docs, nil } On Tue, 2016-09-27 at 14:28 +0930, Dan Kortschak wrote: > Yeah, possibly. Is there is way though to get the associated > ast.CommentGroup for a type's methods? -- 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. For more options, visit https://groups.google.com/d/optout.