func Command(version string, args ...string) *exec.Cmd {
	version = normalizeVersion(version)
	return exec.Command(Path(version), args...)
}
Command instanciates a new command for a given version
package kubectl
import (
	"bytes"
	"fmt"
	"io"
	"net/http"
	"os"
	"os/exec"
	"regexp"
	"runtime"
	"syscall"
	"text/template"
)
var KubectlURLTemplate = "https://storage.googleapis.com/kubernetes-release/release/v{{ .Version }}/bin/{{ .OS }}/{{ .Arch }}/kubectl"
var versionRegexp = regexp.MustCompile("([0-9.]+)")
type kubectlVersion struct {
	Version string
	OS      string
	Arch    string
}
func homeDir() string {
	if h := os.Getenv("HOME"); h != "" {
		return h
	}
	return os.Getenv("USERPROFILE")  
}
func normalizeVersion(version string) string {
	versionRegexp.Longest()
	matches := versionRegexp.FindAllString(version, 1)
	if len(matches) >= 1 {
		return matches[0]
	}
	return ""
}
func URL(version string) string {
	version = normalizeVersion(version)
	t := template.Must(template.New("URL").Parse(KubectlURLTemplate))
	b := bytes.NewBuffer(nil)
	t.Execute(b, &kubectlVersion{
		Version: version,
		OS:      runtime.GOOS,
		Arch:    runtime.GOARCH,
	})
	return b.String()
}
func binDir() string {
	return homeDir() + "/.kube/bin"
}
func Path(version string) string {
	version = normalizeVersion(version)
	return binDir() + "/kubectl-" + version
}
func Download(version string) error {
	version = normalizeVersion(version)
	kubectlURL := URL(version)
	kubectl := Path(version)
	if err := os.MkdirAll(binDir(), 0766); err != nil {
		return fmt.Errorf("failed to create bin directory %s: %s", binDir(), err)
	}
	fmt.Fprintf(os.Stderr, "Downloading kubectl from %s\n", kubectlURL)
	response, err := http.Get(kubectlURL)
	if err != nil {
		return fmt.Errorf("failed to download the kubectl version: %s", err)
	}
	defer response.Body.Close()
	if response.StatusCode != http.StatusOK {
		return fmt.Errorf("failed to download kubectl from %s: %s", kubectlURL, err)
	}
	fd, err := os.Create(kubectl)
	if err != nil {
		return fmt.Errorf("failed to write the kubectl version: %s", err)
	}
	defer fd.Close()
	_, err = io.Copy(fd, response.Body)
	if err != nil {
		return fmt.Errorf("failed to write the kubectl version: %s", err)
	}
	if err := os.Chmod(kubectl, 0766); err != nil {
		return fmt.Errorf("failed to set execution permissions for kubectl: %s", err)
	}
	return nil
}
func Installed(version string) bool {
	version = normalizeVersion(version)
	_, err := os.Stat(Path(version))
	return !os.IsNotExist(err)
}