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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user