Grokking Concurrency in Go
Vote

0% completed

​

The For Select Loop

Output:

tick 1 tick 2 tick 3 reporter stopped after 3 ticks

The reporter goroutine does a small piece of work every 100 ms. It stops at once when main closes done. Its body is a for loop with a select inside, and that combination is called a for-select loop. Most long-running goroutines in Go programs have this form: a worker that takes jobs, a cache that refreshes itself, a server loop that accepts events.

The program is short, but each line in the loop has a reason, and small changes to it cause real bugs

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content