I am trying to download a zip file using a simple http Get. This program downloads the file but the downloaded file is corrupted.
package main import ( "fmt" "io" "net/http" "os" ) func DownloadFile(url string) error { resp, err := http.Get(url) if err != nil { return err } defer resp.Body.Close() filepath := "test.zip" _, err = os.Stat(filepath) if err == nil { err := os.Remove(filepath) if err != nil { return err } } out, err := os.Create(filepath) if err != nil { return err } defer out.Close() _, err = io.Copy(out, resp.Body) if err != nil { return err } return nil } func main() { err := DownloadFile("https://store1.gofile.io/download/78f1898f-2b02-465a-a39c-4cf7e35822a2/test.zip") if err != nil { fmt.Println(err) } } What am I missing here? Regards Gaurav -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/68254497-0003-43dc-99e7-db96a6374390n%40googlegroups.com.