diff options
author | Ian Ling <ian@iancaling.com> | 2022-04-08 08:52:57 -0700 |
---|---|---|
committer | Ian Ling <ian@iancaling.com> | 2022-04-25 15:00:47 -0700 |
commit | 460cf54ece7eba418c50407ee35544c5d63588a7 (patch) | |
tree | 07ec7aaf51a92a1ae209e540f45241f990561919 /examples/5-report/example_report.go | |
parent | fa24fac85dd550a3f815896241081a1246810d2c (diff) | |
download | spdx-tools-460cf54ece7eba418c50407ee35544c5d63588a7.tar.gz |
Overhaul structs, refactor JSON parser and saver
Signed-off-by: Ian Ling <ian@iancaling.com>
Diffstat (limited to 'examples/5-report/example_report.go')
-rw-r--r-- | examples/5-report/example_report.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/examples/5-report/example_report.go b/examples/5-report/example_report.go index bd7971f..1197547 100644 --- a/examples/5-report/example_report.go +++ b/examples/5-report/example_report.go @@ -54,14 +54,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) |