func downloadFile(url string, file *os.File) error {
	resp, err := http.Get(url)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	_, err = io.Copy(file, resp.Body)
	if err != nil {
		return err
	}
	return nil
}
downloadFile will download a file from a URL and write its content to a file
package cmd
import (
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"os/exec"
	"github.com/spf13/cobra"
)
var downloadURL = "https://github.com/hellt/yangpath/raw/master/install.sh"
var upgradeCmd = &cobra.Command{
	Use:   "upgrade",
	Short: "upgrade yangpath",
	Run: func(cmd *cobra.Command, args []string) {
		f, err := ioutil.TempFile("", "yangpath")
		defer os.Remove(f.Name())
		if err != nil {
			log.Fatalf("Failed to create temp file %s\n", err)
		}
		downloadFile(downloadURL, f)
		c := exec.Command("bash", f.Name())
		c.Stdout = os.Stdout
		c.Stderr = os.Stderr
		err = c.Run()
		if err != nil {
			log.Fatalf("cmd.Run() failed with %s\n", err)
		}
	},
}