mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Some more (inelegant) multiple listener code plus some reconfigure support
This commit is contained in:
parent
be8db0c120
commit
82bb95b77f
5 changed files with 103 additions and 31 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue