func GetHostIP() string {
	addrs, err := net.InterfaceAddrs()
	if err != nil {
		return "127.0.0.1"
	}
	for _, address := range addrs {
		if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
			return ipnet.IP.String()
		}
	}
	return "127.0.0.1"
}
GetHostIP return Host IP
package connector
import (
	"fmt"
	"log"
	"net"
	"os/exec"
	"strings"
)
func ExecCmd(name string, arg ...string) (string, error) {
	log.Printf("Command: %s %s:\n", name, strings.Join(arg, " "))
	info, err := exec.Command(name, arg...).CombinedOutput()
	return string(info), err
}
func GetFSType(device string) (string, error) {
	log.Printf("GetFSType: %s\n", device)
	var fsType string
	blkidCmd := "blkid"
	out, err := ExecCmd("blkid", device)
	if err != nil {
		log.Printf("failed to GetFSType: %v cmd: %s output: %s\n",
			err, blkidCmd, string(out))
		return fsType, nil
	}
	for _, v := range strings.Split(string(out), " ") {
		if strings.Contains(v, "TYPE=") {
			fsType = strings.Split(v, "=")[1]
			fsType = strings.Replace(fsType, "\"", "", -1)
			fsType = strings.Replace(fsType, "\n", "", -1)
			fsType = strings.Replace(fsType, "\r", "", -1)
			return fsType, nil
		}
	}
	return fsType, nil
}
func Format(device string, fsType string) error {
	log.Printf("Format device: %s fstype: %s\n", device, fsType)
	mkfsCmd := fmt.Sprintf("mkfs.%s", fsType)
	_, err := exec.LookPath(mkfsCmd)
	if err != nil {
		if err == exec.ErrNotFound {
			return fmt.Errorf("%q executable not found in $PATH", mkfsCmd)
		}
		return err
	}
	mkfsArgs := []string{}
	mkfsArgs = append(mkfsArgs, device)
	if fsType == "ext4" || fsType == "ext3" {
		mkfsArgs = []string{"-F", device}
	}
	out, err := ExecCmd(mkfsCmd, mkfsArgs...)
	if err != nil {
		return fmt.Errorf("formatting disk failed: %v cmd: '%s %s' output: %q",
			err, mkfsCmd, strings.Join(mkfsArgs, " "), string(out))
	}
	return nil
}
func Mount(device, mountpoint, fsType string, mountFlags []string) error {
	log.Printf("Mount device: %s mountpoint: %s, fsType: %s, mountFlags:　%v\n", device, mountpoint, fsType, mountFlags)
	_, err := ExecCmd("mkdir", "-p", mountpoint)
	if err != nil {
		log.Printf("failed to mkdir: %v\n", err)
		return err
	}
	mountArgs := []string{}
	mountArgs = append(mountArgs, "-t", fsType)
	if len(mountFlags) > 0 {
		mountArgs = append(mountArgs, "-o", strings.Join(mountFlags, ","))
	}
	mountArgs = append(mountArgs, device)
	mountArgs = append(mountArgs, mountpoint)
	_, err = exec.Command("mount", mountArgs...).CombinedOutput()
	if err != nil {
		log.Printf("failed to mount: %v\n", err)
		return err
	}
	return nil
}
func Umount(mountpoint string) error {
	log.Printf("Umount mountpoint: %s\n", mountpoint)
	_, err := ExecCmd("umount", mountpoint)
	if err != nil {
		log.Printf("failed to Umount: %v\n", err)
		return err
	}
	return nil
}