Go Routine

Concurrency in Go with calling API requests

Get to know goroutine.

Photo by Priscilla Du Preez on Unsplash

We’ll go over some API requests without go concurrency. For example we want to get data from

"https://www.ncbi.nlm.nih.gov/gene/?term=" + gene

Doing so without concurrency

Will cost


So how do we use go concurrency?

first we need to create waitgroup

wg := sync.WaitGroup{}

Then before move into the go routine, we need to add


Outside the for loop of routines, we wait


That’s it.

Running the code will only take


Happy coding guys ~~~

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