From 68bf5666cdc6805783be7c29fb2a634d8d45bc24 Mon Sep 17 00:00:00 2001 From: Nicolas Owens Date: Thu, 13 Feb 2014 10:26:16 -0500 Subject: [PATCH] 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 --- src/pkg/net/lookup_plan9.go | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.48.1