mirror of
https://github.com/anchore/syft.git
synced 2026-07-05 02:28:25 +02:00
fix: lintfix
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
parent
7050c09094
commit
27f33d0e99
@ -76,7 +76,7 @@ func (c *goBinaryCataloger) recordStdlibSymbols(coord file.Coordinates, symbols
|
|||||||
}
|
}
|
||||||
c.stdlibSymbolsMu.Lock()
|
c.stdlibSymbolsMu.Lock()
|
||||||
defer c.stdlibSymbolsMu.Unlock()
|
defer c.stdlibSymbolsMu.Unlock()
|
||||||
merged := append(c.stdlibSymbols[coord], symbols...)
|
merged := slices.Concat(c.stdlibSymbols[coord], symbols)
|
||||||
slices.Sort(merged)
|
slices.Sort(merged)
|
||||||
c.stdlibSymbols[coord] = slices.Compact(merged)
|
c.stdlibSymbols[coord] = slices.Compact(merged)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// mainPackage is the import path the linker assigns to the binary's main package.
|
||||||
|
const mainPackage = "main"
|
||||||
|
|
||||||
// binarySymbol represents a single function symbol extracted from a go binary's pclntab.
|
// binarySymbol represents a single function symbol extracted from a go binary's pclntab.
|
||||||
type binarySymbol struct {
|
type binarySymbol struct {
|
||||||
// packagePath is the import path of the package that owns the symbol (e.g. "github.com/foo/bar/internal/baz")
|
// packagePath is the import path of the package that owns the symbol (e.g. "github.com/foo/bar/internal/baz")
|
||||||
@ -224,7 +227,7 @@ func moduleSymbols(symbols []binarySymbol, main *debug.Module, deps []*debug.Mod
|
|||||||
results := make(map[string][]string)
|
results := make(map[string][]string)
|
||||||
for _, sym := range symbols {
|
for _, sym := range symbols {
|
||||||
pkgPath := sym.packagePath
|
pkgPath := sym.packagePath
|
||||||
if pkgPath == "main" && main != nil {
|
if pkgPath == mainPackage && main != nil {
|
||||||
// the linker renames the main package's import path to "main"
|
// the linker renames the main package's import path to "main"
|
||||||
pkgPath = main.Path
|
pkgPath = main.Path
|
||||||
}
|
}
|
||||||
@ -236,7 +239,7 @@ func moduleSymbols(symbols []binarySymbol, main *debug.Module, deps []*debug.Mod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if best == "" {
|
if best == "" {
|
||||||
if pkgPath != "main" && isStandardImportPath(pkgPath) {
|
if pkgPath != mainPackage && isStandardImportPath(pkgPath) {
|
||||||
stdlib = append(stdlib, sym.name)
|
stdlib = append(stdlib, sym.name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user