Skip to content

Commit

Permalink
Add convenience method for comparing two SpaceAddresses
Browse files Browse the repository at this point in the history
  • Loading branch information
achilleasa committed Dec 4, 2019
1 parent 37e32d9 commit 4002dae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/network/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,23 @@ func (sas SpaceAddresses) AllMatchingScope(getMatcher ScopeMatchFunc) SpaceAddre
return out
}

// EqualTo returns true if this set of SpaceAddresses is equal to other.
func (sas SpaceAddresses) EqualTo(other SpaceAddresses) bool {
if len(sas) != len(other) {
return false
}

SortAddresses(sas)
SortAddresses(other)
for i := 0; i < len(sas); i++ {
if sas[i].String() != other[i].String() {
return false
}
}

return true
}

// DeriveAddressType attempts to detect the type of address given.
func DeriveAddressType(value string) AddressType {
ip := net.ParseIP(value)
Expand Down

0 comments on commit 4002dae

Please sign in to comment.