package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
out, err := os.Create("output.txt")
defer out.Close()
resp, err := http.Get("https://public.apps.ubuntu.com/anon/download-snap/b8X2psL1ryVrPt5WEmpYiqfr5emixTd7_123.snap")
if err != nil {
fmt.Printf("error %v\n", err);
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
fmt.Printf("HTTP error %d\n", resp.StatusCode);
return
}
fmt.Printf("Downloading %d bytes\n", resp.ContentLength);
n, err := io.Copy(out, resp.Body)
fmt.Printf("%d copied\n", n);
}