func PortUsable(port string) bool {
	addr, err := net.ResolveTCPAddr("tcp", "0.0.0.0:"+port)
	if err != nil {
		return false
	}
	listener, err := net.ListenTCP("tcp", addr)
	defer listener.Close()
	if err != nil {
		return false
	}
	return true
}
Define if a port is already in use on a machine
package utils
import (
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"regexp"
	"strconv"
	"strings"
)
const (
	BashResolver = "\\$[{}0-9a-zA-Z_]+"
)
func OpenFolder(path string) ([]os.FileInfo, error) {
	files, err := ioutil.ReadDir(path)
	if err != nil {
		return nil, err
	}
	return files, nil
}
func OpenFile(path string) (*os.File, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, fmt.Errorf("Failed Open %s\n", path)
	}
	return file, nil
}
func OpenAndReadFile(path string) ([]byte, error) {
	file, err := OpenFile(path)
	if err != nil {
		return nil, err
	}
	b, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, err
	}
	return b, nil
}
func ParseHost(host string, port int) (string, int, error) {
	var uri string
	if port == 0 {
		port = 6666
	}
	address := strings.Split(host, ":")
	if len(address) > 2 {
		return "", 0, fmt.Errorf("Wrong format for %s\n", string(host))
	} else if len(address) == 2 {
		uri = address[0]
		p, err := strconv.Atoi(address[1])
		if err == nil {
			port = p
		}
	} else {
		uri = host
	}
	_, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", uri, port))
	if err != nil {
		return "", 0, fmt.Errorf("Can't resolve %s", host)
	}
	return uri, port, nil
}