Stream + Copy流
func downloadFile(url string, path string) {
defer wg.Done()
// Get the data
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// Create output file
out, err := os.Create(path)
if err != nil {
panic(err)
}
defer out.Close()
// copy stream
_, err = io.Copy(out, resp.Body)
if err != nil {
panic(err)
}
}