// Download the provided url to a temp file, returning the file
Download the provided url to a temp file, returning the file
// Download the provided url to a temp file returning the file
func download(target string, url string) {
	fmt.Printf("Downloading %s...\n", url)
	tmp, err := ioutil.TempFile("", "reference-download")
	util.ExitIfError(err, "Error creating temporary file")
	defer tmp.Close()
	response, err := http.Get(url)
	util.ExitIfError(err, fmt.Sprintf("Error downloading url %s", url))
	defer response.Body.Close()
	_, err = io.Copy(tmp, response.Body)
	util.ExitIfError(err, fmt.Sprintf("Error writing to file %s", tmp))
	os.Rename(tmp.Name(), target)
	fmt.Printf("  -> Stored in %s\n", target)
}
func download ( target string , url string ) { fmt . Printf ( " \n " , url ) tmp , err := ioutil . TempFile ( " " , " " ) util . ExitIfError ( err , " " ) defer tmp . Close ( ) response , err := http . Get ( url ) util . ExitIfError ( err , fmt . Sprintf ( " " , url ) ) defer response . Body . Close ( ) _ , err = io . Copy ( tmp , response . Body ) util . ExitIfError ( err , fmt . Sprintf ( " " , tmp ) ) os . Rename ( tmp . Name ( ) , target ) fmt . Printf ( " \n " , target ) }
Download the provided url to a temp file, returning the file
Download the provided url to a temp file returning the file