
013: Go's concurrency to the rescue
11/30/22 • 14 min
Go's worker queue pattern:
type WorderPool struct {
queue chan int
}
func (wp *WorkerPool) start() {
for i := 0; i < 500; i++ {
go funcIO {
for id := range wp.queue {
doSomething(id)
}
}()
}
}
func (wp *WorkerPool) add(id int) {
wp.queue <- id
}
Best way to show support for the pod is by sharing it around and buying my course.
Go's worker queue pattern:
type WorderPool struct {
queue chan int
}
func (wp *WorkerPool) start() {
for i := 0; i < 500; i++ {
go funcIO {
for id := range wp.queue {
doSomething(id)
}
}()
}
}
func (wp *WorkerPool) add(id int) {
wp.queue <- id
}
Best way to show support for the pod is by sharing it around and buying my course.
Previous Episode

012: Concurrency isn't Go main selling point
Let's talk about Go's concurrency. It's a powerful tool to have at your disposal but a hard one to master and use correctly.
- The tweet that inspired this episode, I thought it was a recent one though...
- Reach out on Twitter
- Build SaaS apps in Go
If you want to support the pod the best way is to purchase my course (thanks).
Next Episode

014: We should contribute more to open source
This is the last episode of 2022. Those are my thoughts about how I think we should try to help more as user of open source project and librairies.
This episode content was inspired by the Gorilla Web Tool Kit archiving their Go projects.
On that note, I'll be back with more Go content on January, and will try to keep my 1 episode per two weeks plan for 2023.
Thank you!
If you like this episode you’ll love
Episode Comments
Generate a badge
Get a badge for your website that links back to this episode
<a href="https://goodpods.com/podcasts/go-podcast-481108/013-gos-concurrency-to-the-rescue-64380014"> <img src="https://storage.googleapis.com/goodpods-images-bucket/badges/generic-badge-1.svg" alt="listen to 013: go's concurrency to the rescue on goodpods" style="width: 225px" /> </a>
Copy