feat: rework filters

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
Matthis Holleville
2023-03-31 15:43:52 +02:00
parent 975813d328
commit 3ed545f33f
6 changed files with 65 additions and 31 deletions

View File

@@ -82,3 +82,17 @@ func RemoveDuplicates(slice []string) ([]string, []string) {
}
return uniqueSlice, duplicates
}
func SliceDiff(source, dest []string) []string {
mb := make(map[string]struct{}, len(dest))
for _, x := range dest {
mb[x] = struct{}{}
}
var diff []string
for _, x := range source {
if _, found := mb[x]; !found {
diff = append(diff, x)
}
}
return diff
}