diff options
Diffstat (limited to 'examples/1-load/example_load.go')
-rw-r--r-- | examples/1-load/example_load.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/examples/1-load/example_load.go b/examples/1-load/example_load.go index 12563d2..328d349 100644 --- a/examples/1-load/example_load.go +++ b/examples/1-load/example_load.go @@ -62,14 +62,26 @@ func main() { return } + if len(pkgIDs) == 0 { + return + } + // it does, so we'll go through each one - for _, pkgID := range pkgIDs { - pkg, ok := doc.Packages[pkgID] - if !ok { - fmt.Printf("Package %s has described relationship but ID not found\n", string(pkgID)) + for _, pkg := range doc.Packages { + var documentDescribesPackage bool + for _, describedPackageID := range pkgIDs { + if pkg.PackageSPDXIdentifier == describedPackageID { + documentDescribesPackage = true + break + } + } + + if !documentDescribesPackage { continue } + pkgID := pkg.PackageSPDXIdentifier + // check whether the package had its files analyzed if !pkg.FilesAnalyzed { fmt.Printf("Package %s (%s) had FilesAnalyzed: false\n", string(pkgID), pkg.PackageName) @@ -93,7 +105,7 @@ func main() { // from a map. if we care about order, we should first pull the // IDs into a slice, sort it, and then print the ordered files. fmt.Printf("- File %d: %s\n", i, f.FileName) - fmt.Printf(" License from file: %v\n", f.LicenseInfoInFile) + fmt.Printf(" License from file: %v\n", f.LicenseInfoInFiles) fmt.Printf(" License concluded: %v\n", f.LicenseConcluded) i++ if i > 50 { |