Download a File from a URL
This post shows you how to download a file in Go from the internet to your computer. We use the standard lib http.Get() and io.Copy() functions to help us with it. This function should be efficient as it will stream the data into the file, as aposed to downloading it all into memory, then to file. We also show an alternative below if you want to take the filename from the URL.