func WaitForConnect(ctx context.Context, addresses []string) error {
	var d net.Dialer
	var errs []error
	for {
		errs = nil
		for _, addr := range addresses {
			if addr == "" {
				continue
			}

			// TODO: golang 15.3 introduces tls.DialContext(). When we are ready to drop
			//  support for older versions we can detect tls and use the tls.DialContext to
			//  avoid the `http: TLS handshake error` we get when using TLS.
			conn, err := d.DialContext(ctx, "tcp", addr)
			if err != nil {
				errs = append(errs, err)
				continue
			}
			conn.Close()
		}

		if len(errs) == 0 {
			break
		}

		select {
		case <-ctx.Done():
			return ctx.Err()
		}
	}

	if len(errs) != 0 {
		var errStrings []string
		for _, err := range errs {
			errStrings = append(errStrings, err.Error())
		}
		return errors.New(strings.Join(errStrings, "\n"))
	}
	return nil
}
// WaitForConnect returns nil if the list of addresses is listening
// for connections; will block until context is cancelled.
WaitForConnect returns nil if the list of addresses is listening
for connections; will block until context is cancelled.
// WaitForConnect returns nil if the list of addresses is listening // for connections ; will block until context is cancelled .
func WaitForConnect(ctx context.Context, addresses []string) error {
	var d net.Dialer
	var errs []error
	for {
		errs = nil
		for _, addr := range addresses {
			if addr == "" {
				continue
			}
			conn, err := d.DialContext(ctx, "tcp", addr)
			if err != nil {
				errs = append(errs, err)
				continue
			}
			conn.Close()
		}
		if len(errs) == 0 {
			break
		}
		select {
		case <-ctx.Done():
			return ctx.Err()
		}
	}
	if len(errs) != 0 {
		var errStrings []string
		for _, err := range errs {
			errStrings = append(errStrings, err.Error())
		}
		return errors.New(strings.Join(errStrings, "\n"))
	}
	return nil
}
func WaitForConnect ( ctx context . Context , addresses [ ] string ) error { var d net . Dialer var errs [ ] error for { errs = nil for _ , addr := range addresses { if addr == " " { continue } conn , err := d . DialContext ( ctx , " " , addr ) if err != nil { errs = append ( errs , err ) continue } conn . Close ( ) } if len ( errs ) == 0 { break } select { case <- ctx . Done ( ) : return ctx . Err ( ) } } if len ( errs ) != 0 { var errStrings [ ] string for _ , err := range errs { errStrings = append ( errStrings , err . Error ( ) ) } return errors . New ( strings . Join ( errStrings , " \n " ) ) } return nil }
WaitForConnect returns nil if the list of addresses is listening
for connections; will block until context is cancelled.
WaitForConnect returns nil if the list of addresses is listening for connections ; will block until context is cancelled .
// TODO: golang 15.3 introduces tls.DialContext(). When we are ready to drop //  support for older versions we can detect tls and use the tls.DialContext to //  avoid the `http: TLS handshake error` we get when using TLS.