This article demonstrates the use of Goroutines & WaitGroups for writing concurrent programs in GoLang.
In GoLang, when we use the
go keyword means starting a new goroutine to perform a specific job in the background. Think of a goroutine as a thread to understand this article – although goroutines are not threads. Meanwhile, the caller function will go ahead & can continue to execute its next lines.
Note here that, the
go keyword-only instructs the program to start a new background job and says nothing about how those background jobs will return back and merge into the caller function – that’s the job of WaitGroups and we will cover that as well in this article.