waitforit/waitforit.go
func WaitForIt(fullConn, host string, port, timeout int) error {
	// fullConn := flag.String("full-connection", "", "full connection")
	// host := flag.String("host", "", "host to connect")
	// port := flag.Int("port", 80, "port to connect")
	// timeout := flag.Int("timeout", 10, "time to wait until port become available")
	// printVersion := flag.Bool("v", false, "show the current version")
	// debug = flag.Bool("debug", false, "enable debug")

	// flag.Parse()

	// if *printVersion {
	// 	fmt.Println("waitforit version " + VERSION)
	// 	return
	// }

	conn := buildConn(host, port, fullConn)
	if conn == nil {
		return errors.New("Invalid connection")
	}

	log.Debug("Waiting " + strconv.Itoa(timeout) + " seconds")
	if err := pingTCP(conn, timeout); err != nil {
		return err
	}

	if conn.Scheme != "http" && conn.Scheme != "https" {
		return nil
	}

	if err := pingHTTP(conn, timeout); err != nil {
		return err
	}

	return nil
}
func WaitForIt(fullConn, host string, port, timeout int) error {
	// fullConn := flag.String("full-connection", "", "full connection")
	// host := flag.String("host", "", "host to connect")
	// port := flag.Int("port", 80, "port to connect")
	// timeout := flag.Int("timeout", 10, "time to wait until port become available")
	// printVersion := flag.Bool("v", false, "show the current version")
	// debug = flag.Bool("debug", false, "enable debug")

	// flag.Parse()

	// if *printVersion {
	// 	fmt.Println("waitforit version " + VERSION)
	// 	return
	// }

	conn := buildConn(host, port, fullConn)
	if conn == nil {
		return errors.New("Invalid connection")
	}

	log.Debug("Waiting " + strconv.Itoa(timeout) + " seconds")
	if err := pingTCP(conn, timeout); err != nil {
		return err
	}

	if conn.Scheme != "http" && conn.Scheme != "https" {
		return nil
	}

	if err := pingHTTP(conn, timeout); err != nil {
		return err
	}

	return nil
}
// WaitForIt waits for a service or URL to become online