port golang cataloger to new generic cataloger pattern (#1289)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2022-10-25 16:42:50 +00:00
committed by GitHub
parent 52cb7269bf
commit 6826d7603b
12 changed files with 294 additions and 239 deletions
-8
View File
@@ -1,7 +1,6 @@
package pkg
import (
"regexp"
"sort"
"strings"
@@ -42,13 +41,6 @@ func URL(p Package, release *linux.Release) string {
switch {
case purlType == "":
purlType = packageurl.TypeGeneric
case p.Type == GoModulePkg:
re := regexp.MustCompile(`(/)[^/]*$`)
fields := re.Split(p.Name, -1)
if len(fields) > 1 {
namespace = fields[0]
name = strings.TrimPrefix(p.Name, namespace+"/")
}
case p.Type == NpmPkg:
fields := strings.SplitN(p.Name, "/", 2)
if len(fields) > 1 {