code: func randListenFn(listenAddr string, randPortFn func() (int, error)) (string, error) {
  	portIdx := strings.LastIndex(listenAddr, ":") + 1
  	if portIdx <= 0 || portIdx >= len(listenAddr) {
  		return "", errors.New("invalid listen addr, no port found")
  	}
  	port, err := randPortFn()
  	if err != nil {
  		return "", err
  	}
  	return fmt.Sprintf("%s%d", listenAddr[:portIdx], port), nil
  }
docs: // randListenFn only exists to allow testing of randListen, by letting the caller
  // replace randPort with a func that actually has a predictable result.