refractor: use internal Intersect function.

This commit is contained in:
Alexandre Pujol 2024-06-19 23:55:45 +01:00
parent 3b82cc36ba
commit b0f6f15a9e
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 69 additions and 3 deletions

View file

@ -82,6 +82,25 @@ func RemoveDuplicate[T comparable](inlist []T) []T {
return list
}
// Intersect returns the intersection between two collections.
// From https://github.com/samber/lo
func Intersect[T comparable](list1 []T, list2 []T) []T {
result := []T{}
seen := map[T]struct{}{}
for _, elem := range list1 {
seen[elem] = struct{}{}
}
for _, elem := range list2 {
if _, ok := seen[elem]; ok {
result = append(result, elem)
}
}
return result
}
// CopyTo recursivelly copy all files from a source path to a destination path.
func CopyTo(src *paths.Path, dst *paths.Path) error {
files, err := src.ReadDirRecursiveFiltered(nil,