code: func (c *Client) startupHealthcheck(parentCtx context.Context, timeout time.Duration) error {
  	c.mu.Lock()
  	urls := c.urls
  	basicAuth := c.basicAuth
  	basicAuthUsername := c.basicAuthUsername
  	basicAuthPassword := c.basicAuthPassword
  	c.mu.Unlock()
  
  	// If we don't get a connection after "timeout", we bail.
  	var lastErr error
  	start := time.Now()
  	done := false
  	for !done {
  		for _, url := range urls {
  			req, err := http.NewRequest("HEAD", url, nil)
  			if err != nil {
  				return err
  			}
  			if basicAuth {
  				req.SetBasicAuth(basicAuthUsername, basicAuthPassword)
  			}
  			ctx, cancel := context.WithTimeout(parentCtx, timeout)
  			defer cancel()
  			req = req.WithContext(ctx)
  			res, err := c.c.Do(req)
  			if err == nil && res != nil && res.StatusCode >= 200 && res.StatusCode < 300 {
  				return nil
  			} else if err != nil {
  				lastErr = err
  			}
  		}
  		select {
  		case <-parentCtx.Done():
  			lastErr = parentCtx.Err()
  			done = true
  			break
  		case <-time.After(1 * time.Second):
  			if time.Since(start) > timeout {
  				done = true
  				break
  			}
  		}
  	}
  	if lastErr != nil {
  		if IsContextErr(lastErr) {
  			return lastErr
  		}
  		return errors.Wrapf(ErrNoClient, "health check timeout: %v", lastErr)
  	}
  	return errors.Wrap(ErrNoClient, "health check timeout")
  }
docs: // startupHealthcheck is used at startup to check if the server is available
  // at all.