From: Nicolas Owens Date: Thu, 13 Feb 2014 15:26:16 +0000 (-0500) Subject: net: only return unique hosts during hostname lookup on plan 9 X-Git-Tag: go1.3beta1~732 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=68bf5666cdc6805783be7c29fb2a634d8d45bc24;p=gostls13.git 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 --- diff --git a/src/pkg/net/lookup_plan9.go b/src/pkg/net/lookup_plan9.go index 723f29ffce..2ccd997c2c 100644 --- a/src/pkg/net/lookup_plan9.go +++ b/src/pkg/net/lookup_plan9.go @@ -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