4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-06-16 00:56:09 +00:00

Some more (inelegant) multiple listener code plus some reconfigure support

This commit is contained in:
Neil Alexander
2019-03-04 18:41:32 +00:00
parent be8db0c120
commit 82bb95b77f
5 changed files with 103 additions and 31 deletions

View File

@ -76,3 +76,20 @@ func FuncTimeout(f func(), timeout time.Duration) bool {
return false
}
}
// This calculates the difference between two arrays and returns items
// that appear in A but not in B - useful somewhat when reconfiguring
// and working out what configuration items changed
func Difference(a, b []string) []string {
ab := []string{}
mb := map[string]bool{}
for _, x := range b {
mb[x] = true
}
for _, x := range a {
if _, ok := mb[x]; !ok {
ab = append(ab, x)
}
}
return ab
}