Practical Concurrency in Go - GoRoutines, Mutexes, Channels and more

3,582
13
Publicado 2024-05-03
#golang #coding #concurrency #threads #tutorial #programming

In this video I give some examples of writing concurrent programs in Go, using an example of writing a simple Currency Exchange that fetches currency exchange rates.

We start by running it with no concurrency, then we implement goroutines fetching in parallel and finally we create a worker pool of threads and channels to enqueue work and dequeue results coming back.

Hope you enjoy it!

This video's tutorial repo: github.com/sigrdrifa/go-concurrency
The Currency API: github.com/fawazahmed0/exchange-api?tab=readme-ov-…
My NVIM config: github.com/sigrdrifa/nvim

Todos los comentarios (11)
  • @AnandKumar-dc2bf
    Thanks for ur videos pls make more and more golang videos please.....
  • @frankjansson7563
    I've been wanting to get started with Go these videos are really enjoyable. I enjoy your Non Go videos to. Keep spreading the joy of coding :)
  • @veronez9846
    one of the bests videos about concurrency.
  • @dejanduh2645
    This is the best practical example of concurrency in go I have ever seen. Great job, keep up 👍
  • @baronbeans5001
    This was so helpful. Any chance you can do a video on context in go?
  • @manishbadgotra
    You really are a Good teacher 💯 btw Love from India ❤
  • the example at 10:30 cannot be correct, the error is caused by the fact that there is no Currency item in the currencies map with key 'usd' at the time the go routine outside of the waiting group is running. If you add a 'usd' currency in the code above the error is gone and it prints the rates when it has the record whenever the thread has a chance to run. Also at 22:40 you say let's close the resultChan but the code below has close(currencyChan). The question is why closing only one? why not both or why any at all?