func DownloadFile(file string, url string) (bool, error) {
	r, err := http.Get(url)
	if err != nil {
		return false, err
	}
	defer r.Body.Close()
	out, err := os.Create(file)
	if err != nil {
		return false, err
	}
	defer out.Close()
	_, err = io.Copy(out, r.Body)
	return false, err
}
DownloadFile will download a url to a local file. It's like WGET
package utils
import (
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"text/template"
	log "github.com/sirupsen/logrus"
	"sigs.k8s.io/cluster-api/cmd/clusterctl/client"
)
func CheckPreReqs(lastinstalldir string) (bool, error) {
	log.Info("Running checks")
	cliUtils := [3]string{"kubectl", "docker", "git"}
	for _, cli := range cliUtils {
		_, err := exec.LookPath(cli)
		if err != nil {
			log.Warn("Nonfatal: ", err)
		}
	}
	if _, err := os.Stat(lastinstalldir); !os.IsNotExist(err) {
		log.Fatal("Ooops! Looks like there are stray artifacts found: ", lastinstalldir)
	}
	return true, nil
}
func CreateWorkDir() (string, error) {
	gokphome := os.Getenv("HOME") + "/.gokp"
	dir, err := ioutil.TempDir(gokphome, ".gokpinstall")
	if err != nil {
		return "", err
	}
	return dir, nil
}
func WriteTemplate(tpl string, fileToCreate string, vars interface{}) (bool, error) {
	tmpl := template.Must(template.New("").Parse(tpl))
	file, err := os.Create(fileToCreate)
	if err != nil {
		return false, err
	}
	err = tmpl.Execute(file, vars)
	if err != nil {
		file.Close()
		return false, err
	}
	file.Close()
	return true, nil
}
func WriteYamlOutput(printer client.YamlPrinter, file string) error {
	f, err := os.Create(file)
	if err != nil {
		return err
	}
	defer f.Close()
	yaml, err := printer.Yaml()
	yaml = append(yaml, '\n')
	if err != nil {
		return err
	}
	if _, err := f.Write(yaml); err != nil {
		return err
	}
	return nil
}
func SplitYamls(dir string, yaml string, spliton string) error {
	yamlByte, err := ioutil.ReadFile(yaml)
	if err != nil {
		return err
	}
	yml := string(yamlByte)
	files := strings.Split(yml, spliton)
	for i, file := range files {
		if err := os.MkdirAll(dir, 0755); err != nil {
			return err
		}
		newYaml, err := os.Create(dir + "/" + fmt.Sprintf("%02d", i) + "." + filepath.Base(yaml))
		if err != nil {
			return err
		}
		defer newYaml.Close()
		newYaml.WriteString(file)
	}
	return nil
}