From be857a63658653828248cd080bc8a33d3893135a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 25 Apr 2019 09:01:11 +0200 Subject: [PATCH] net: fix lookupHost to return DNSError on Plan 9 CL 168597 added IsNotFound field to DNSError. However, this change broke TestLookupNonLDH on Plan 9 because LookupHost is expected to return a DNSError, while on Plan 9, it returned an error string. This change fixes the implementation of lookupHost on Plan 9 to return a DNSError instead of an error string. Fixes #31672. Change-Id: Ia805c8965af63ddee7ccfdebb9462a5502b0269d Reviewed-on: https://go-review.googlesource.com/c/go/+/173857 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/net/lookup_plan9.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net/lookup_plan9.go b/src/net/lookup_plan9.go index 70805ddf4c..6a2d48eeda 100644 --- a/src/net/lookup_plan9.go +++ b/src/net/lookup_plan9.go @@ -147,10 +147,12 @@ func (*Resolver) lookupHost(ctx context.Context, host string) (addrs []string, e // host names in local network (e.g. from /lib/ndb/local) lines, err := queryCS(ctx, "net", host, "1") if err != nil { + dnsError := &DNSError{Err: err.Error(), Name: host} if stringsHasSuffix(err.Error(), "dns failure") { - err = errNoSuchHost + dnsError.Err = errNoSuchHost.Error() + dnsError.IsNotFound = true } - return + return nil, dnsError } loop: for _, line := range lines {