mirror of
https://github.com/golang/go
synced 2024-11-05 18:36:08 +00:00
net: only return unique hosts during hostname lookup on plan 9
TestLookupHost expects that no duplicate addresses are returned. when cs is consulted for a name, e.g net!localhost!1, it will possibly return multiple available paths, e.g. via il and tcp. this confuses the tests. LGTM=aram R=jas, 0intro, aram CC=golang-codereviews https://golang.org/cl/58120045
This commit is contained in:
parent
87d58f44a1
commit
68bf5666cd
1 changed files with 7 additions and 0 deletions
|
@ -123,6 +123,7 @@ func lookupHost(host string) (addrs []string, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
loop:
|
||||
for _, line := range lines {
|
||||
f := getFields(line)
|
||||
if len(f) < 2 {
|
||||
|
@ -135,6 +136,12 @@ func lookupHost(host string) (addrs []string, err error) {
|
|||
if ParseIP(addr) == nil {
|
||||
continue
|
||||
}
|
||||
// only return unique addresses
|
||||
for _, a := range addrs {
|
||||
if a == addr {
|
||||
continue loop
|
||||
}
|
||||
}
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue