func WaitForListener(network, address string, timeout time.Duration) error {
	start := time.Now()
	var lastErr error
	for time.Since(start) < timeout {
		if lastErr = tryDial(network, address); lastErr == nil {
			break
		}
		time.Sleep(100 * time.Millisecond)
	}
	return lastErr
}
WaitForListener tries to connect to the given TCP addr and returns
nil or the last error occurred when trying to dial that addr, in case
of timeout.
package netutil
import (
	"net"
	"time"
)