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:
Nicolas Owens 2014-02-13 10:26:16 -05:00 committed by Russ Cox
parent 87d58f44a1
commit 68bf5666cd

View file

@ -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