mirror of
https://github.com/anchore/grype
synced 2024-09-20 14:31:59 +00:00
2647cd0d9e
* port grype-db to grype Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate vulnerability provider implementation to db package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * upgrade path import validations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting issues Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
38 lines
577 B
Go
38 lines
577 B
Go
package internal
|
|
|
|
type StringSet map[string]struct{}
|
|
|
|
func NewStringSet() StringSet {
|
|
return make(StringSet)
|
|
}
|
|
|
|
func NewStringSetFromSlice(start []string) StringSet {
|
|
ret := make(StringSet)
|
|
for _, s := range start {
|
|
ret.Add(s)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
func (s StringSet) Add(i string) {
|
|
s[i] = struct{}{}
|
|
}
|
|
|
|
func (s StringSet) Remove(i string) {
|
|
delete(s, i)
|
|
}
|
|
|
|
func (s StringSet) Contains(i string) bool {
|
|
_, ok := s[i]
|
|
return ok
|
|
}
|
|
|
|
func (s StringSet) ToSlice() []string {
|
|
ret := make([]string, len(s))
|
|
idx := 0
|
|
for v := range s {
|
|
ret[idx] = v
|
|
idx++
|
|
}
|
|
return ret
|
|
}
|