Standard library / go/doc
go/doc.AllMethods
Includes embedded methods from visible embedded types as well. Expected stdout: 'B Work\n'.
Formal Syntax & Structure
go syntaxgo
const AllMethods Mode = 2Working Example
Example Snippetgo
package main
import ( "fmt" "go/ast" "go/doc" "go/parser" "go/token")
func check(e error) { if e != nil { panic(e) }}
func main() { fs := token.NewFileSet() f, e := parser.ParseFile(fs, "demo.go", "package demo;type A struct{};func(A) Work(){};type B struct{A}", 0) check(e) p, e := doc.NewFromFiles(fs, []*ast.File{f}, "demo", doc.AllMethods) check(e) fmt.Println(p.Types[1].Name, p.Types[1].Methods[0].Name)}