mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
Add imports dumper
This commit is contained in:
parent
2c9d8fc461
commit
b02c0fa2fc
1 changed files with 16 additions and 0 deletions
16
tools.go
16
tools.go
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue