diff --git a/src/net/hook.go b/src/net/hook.go new file mode 100644 index 0000000000..14dc19f68f --- /dev/null +++ b/src/net/hook.go @@ -0,0 +1,7 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package net + +var testHookLookupIP = func(fn func(string) ([]IPAddr, error), host string) ([]IPAddr, error) { return fn(host) } diff --git a/src/net/lookup.go b/src/net/lookup.go index 65abc81309..be4b0c2df6 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -46,7 +46,7 @@ var lookupGroup singleflight // is always owned by the caller. func lookupIPMerge(host string) (addrs []IPAddr, err error) { addrsi, err, shared := lookupGroup.Do(host, func() (interface{}, error) { - return lookupIP(host) + return testHookLookupIP(lookupIP, host) }) return lookupIPReturn(addrsi, err, shared) } @@ -84,7 +84,7 @@ func lookupIPDeadline(host string, deadline time.Time) (addrs []IPAddr, err erro defer t.Stop() ch := lookupGroup.DoChan(host, func() (interface{}, error) { - return lookupIP(host) + return testHookLookupIP(lookupIP, host) }) select {