Remove internal string set (#2219)

* remove internal string set

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* incorporate changes from #2227

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* beef up the pkg.License.Merg() doc string

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-10-17 12:52:11 -04:00
committed by GitHub
parent f3ad8cf250
commit 7018573bf7
24 changed files with 346 additions and 163 deletions
+4 -3
View File
@@ -6,7 +6,8 @@ import (
"sort"
"strings"
"github.com/anchore/syft/internal"
"github.com/scylladb/go-set/strset"
"github.com/anchore/syft/internal/log"
)
@@ -40,7 +41,7 @@ func (z ZipFileManifest) Add(entry string, info os.FileInfo) {
// GlobMatch returns the path keys that match the given value(s).
func (z ZipFileManifest) GlobMatch(patterns ...string) []string {
uniqueMatches := internal.NewStringSet()
uniqueMatches := strset.New()
for _, pattern := range patterns {
for entry := range z {
@@ -54,7 +55,7 @@ func (z ZipFileManifest) GlobMatch(patterns ...string) []string {
}
}
results := uniqueMatches.ToSlice()
results := uniqueMatches.List()
sort.Strings(results)
return results
+6 -9
View File
@@ -1,20 +1,21 @@
package licenses
import "github.com/anchore/syft/internal"
// all of these taken from https://github.com/golang/pkgsite/blob/8996ff632abee854aef1b764ca0501f262f8f523/internal/licenses/licenses.go#L338
// which unfortunately is not exported. But fortunately is under BSD-style license. Take note that this list has
// been manually updated to include more license filenames (see https://github.com/anchore/syft/pull/2227).
var (
FileNames = []string{
func FileNames() []string {
return []string{
"AL2.0",
"COPYING",
"COPYING.md",
"COPYING.markdown",
"COPYING.txt",
"LGPL2.1",
"LICENCE",
"LICENCE.md",
"LICENCE.markdown",
"licence.txt",
"LICENCE.txt",
"LICENSE",
"LICENSE.md",
@@ -49,9 +50,5 @@ var (
"MIT_LICENCE",
"UNLICENSE",
"UNLICENCE",
"AL2.0",
"LGPL2.1",
}
FileNameSet = internal.NewStringSet(FileNames...)
)
}