Concurrent HTTP downloads using Go

Image courtesy — https://hackernoon.com/why-we-love-concurrency-and-you-should-too-c64c2d08a059
resp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
Download a file represented by a public url
Download multiple files using goroutines & channels
bytesArray = append(bytesArray, <-done)  
if err := <-errch; err != nil {
errStr = errStr + " " + err.Error()
}

--

--

--

Co-founder & CTO @geektrust. Gopher. Polyglot.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dhanush Gopinath

Dhanush Gopinath

Co-founder & CTO @geektrust. Gopher. Polyglot.

More from Medium

[Solution]Exercise: Maps | A Tour of Go

Part 2: Grpc Proto Code Generation Using Protoc for Message and Services

Using assert in go tests