

They are functions that run concurrently with other functions.

A goroutine is Go’s way of achieving concurrency.

What is this concurrent model? In Go, it is simply creating multiple goroutines to handle parts of the processes. It would not make any sense to download this resource sequentially (trust me, I tried).īy using a concurrent model, I was able to implement a Worker pool (to be explained later) to handle multiple HTTP requests at a time, keeping the connection alive and getting multiple results in a very short time. If you happen to be very patient, there is still a very high chance the operation would fail due to factors such as the rate limiting feature on the website. To do this sequentially (that is, one at a time), it would take a long time (probably hours). As stated earlier, the xkcd website has over 2500 comics to download. Much has been written on the concurrency feature of Go so I’ll just share my experience on what I know it does for this project. At the time of writing, there are over 2500 comics (URLs) to download.
SG PROJECT GO OFFLINE
The program fetches issues from the xkcd comics website and downloads each URL to build an offline JSON index. In this article, I will share my experience with concurrency with the aid of a small tool. What stood out most to me was the simplistic approach to lower level operations in Go, ranging from references and pointers to concurrency. Coming from a PHP background, I instantly fell in love with Go after checking out the syntax and building small projects with it.
