Skip to content

Commit

Permalink
chore: don't allocate string slice unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasschafer committed Feb 7, 2025
1 parent cae78c1 commit cc45f98
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/utils/spdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ func GetPurlFromSPDXPackage(pkg *spdx_2_3.Package) (*packageurl.PackageURL, erro
}

func GetLicensesFromEcosystemsLicense(pkgVersionData *packages.VersionWithDependencies, pkgData *packages.Package) []string {
licenses := []string{}
if pkgVersionData != nil && pkgVersionData.Licenses != nil && *pkgVersionData.Licenses != "" {
licenses = strings.Split(*pkgVersionData.Licenses, ",")
return strings.Split(*pkgVersionData.Licenses, ",")
} else if pkgData != nil && len(pkgData.NormalizedLicenses) > 0 {
licenses = pkgData.NormalizedLicenses
return pkgData.NormalizedLicenses
}
return licenses
return nil
}

func GetLicenseExpressionFromEcosystemsLicense(pkgVersionData *packages.VersionWithDependencies, pkgData *packages.Package) string {
Expand Down

0 comments on commit cc45f98

Please sign in to comment.