This repo is for golang concurrency patterns after reading Concurrency in Go. I modified some examples for better understanding.
- Buffered or unbuffered channel both are okay, they don't affect these examples. But for memory efficiency, I prefer unbuffered channel.
- Reorder the pattern for easily learning based on my opinion. So there might be some differences between repo and book.
- In each example, it will print
expected 1 goroutine, got goroutine: 1. That means the program closes all goroutines safely (except main goroutine) to avoid goroutine leaks.
There is an simple introduction article written in Chinese. Feel free to read it.
| Concurrency Pattern |
|---|
| 01: Generator |
| 02: Done channel |
| 03: Pipeline |
| 04: Fan-In |
| 05: Fan-Out |
| 06: Fan-In and Fan-Out |
| 07: Or-Channel |
| 08: Or-Done-Channel |
| 09: Tee-Channel |
| 10: Bridge-Channel |
These examples are built with above related concepts.
| Other Usage |
|---|
| 01: Graceful Shutdown |
| 02: Pub/Sub |
| 03: Worker Pool |