mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-25 01:23:22 +01:00
17 lines
355 B
Go
17 lines
355 B
Go
|
package util
|
||
|
|
||
|
// SliceDiff returns the elements in slice `x` that are not in slice `y`
|
||
|
func SliceDiff(x, y []string) []string {
|
||
|
mapY := make(map[string]struct{}, len(y))
|
||
|
for _, val := range y {
|
||
|
mapY[val] = struct{}{}
|
||
|
}
|
||
|
var diff []string
|
||
|
for _, val := range x {
|
||
|
if _, found := mapY[val]; !found {
|
||
|
diff = append(diff, val)
|
||
|
}
|
||
|
}
|
||
|
return diff
|
||
|
}
|