package demo type People struct { Name string Age uint } type UserInfo struct { Address string Hobby
Using go/importer:
pkg, err := importer.Default().Import("time") if err != nil { fmt.Println("error:", err) return } for _, declName := range pkg.Scope().Names() { fmt.Println(declName) }
(note, this returns an error on the Go Playground).