This commit is contained in:
2026-04-21 18:19:42 +02:00
parent 5b5b6aa795
commit f5126ad37c
3 changed files with 47 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"fmt"
"go/token"
"golang.org/x/tools/go/packages"
)
func main() {
cfg := &packages.Config{
Mode: packages.NeedTypes,
}
pkgs, err := packages.Load(cfg, "fmt")
if err != nil {
panic(err)
}
for _, pkg := range pkgs {
scope := pkg.Types.Scope()
for _, name := range scope.Names() {
if !token.IsExported(name) {
continue
}
obj := scope.Lookup(name)
fmt.Println(name, obj.Type())
}
}
}