Add imports dumper

This commit is contained in:
Grant Murphy 2016-11-06 12:15:32 -08:00
parent 2c9d8fc461
commit b02c0fa2fc

View file

@ -40,6 +40,7 @@ func newUtils() *utilities {
utils["types"] = dumpTypes utils["types"] = dumpTypes
utils["defs"] = dumpDefs utils["defs"] = dumpDefs
utils["comments"] = dumpComments utils["comments"] = dumpComments
utils["imports"] = dumpImports
return &utilities{utils, make([]string, 0)} return &utilities{utils, make([]string, 0)}
} }
@ -218,3 +219,18 @@ func dumpComments(files ...string) {
} }
} }
} }
func dumpImports(files ...string) {
for _, file := range files {
if shouldSkip(file) {
continue
}
context := createContext(file)
for _, pkg := range context.pkg.Imports() {
fmt.Println(pkg.Path(), pkg.Name())
for _, name := range pkg.Scope().Names() {
fmt.Println(" => ", name)
}
}
}
}