code: func HostPort(urlStr string) (string, error) {
  	// TODO: rename this function to URLHostPort instead, like
  	// ListenHostPort below.
  	u, err := url.Parse(urlStr)
  	if err != nil {
  		return "", fmt.Errorf("could not parse %q as a url: %v", urlStr, err)
  	}
  	if u.Scheme == "" {
  		return "", fmt.Errorf("url %q has no scheme", urlStr)
  	}
  	hostPort := u.Host
  	if hostPort == "" || strings.HasPrefix(hostPort, ":") {
  		return "", fmt.Errorf("url %q has no host", urlStr)
  	}
  	idx := strings.Index(hostPort, "]")
  	if idx == -1 {
  		idx = 0
  	}
  	if !strings.Contains(hostPort[idx:], ":") {
  		if u.Scheme == "https" {
  			hostPort += ":443"
  		} else {
  			hostPort += ":80"
  		}
  	}
  	return hostPort, nil
  }
docs: // HostPort takes a urlStr string URL, and returns a host:port string suitable
  // to passing to net.Dial, with the port set as the scheme's default port if
  // absent.