Build the safeguards
Eight explained steps, tradeoffs, pitfalls and a checkpoint before moving on.
Read the tutorialGo / Concurrency / Cancellation
The customer cancels. The collector stops. The workers keep waiting. See the difference between starting concurrent work and owning its whole lifetime.
A goroutine needs an owner and a way to finish. A bounded worker pool limits active work; cancellation must reach both producers and workers; joining them establishes that shutdown has actually completed.
The browser runs the same Go engine compiled to WebAssembly inside a dedicated worker. Goroutines run concurrently, but this browser target is not a multicore throughput benchmark. A harness cleans up the deliberately blocked example after recording it. The native download includes an HTTP adapter and Go tests.
Your independent testing environment
Keep the default 12 messages, 3 workers and early cancellation. Run without safeguards, then with safeguards. Compare peak active work and workers left at cancellation. Reset starts over and stops pending work.
Ready to try
Your result and database records will appear here.
Show the canceled collector first. Explain who owns the queue, who closes it, how blocked work stops and why the function waits for workers. Separate concurrency safety from the delivery guarantee.
Use the code viewer to inspect the original source that produced this release. Each file is checked against the release manifest before it is displayed. The complete download includes the runnable example, tests, setup instructions and third-party notices.
Keep exploring
Eight explained steps, tradeoffs, pitfalls and a checkpoint before moving on.
Read the tutorialChoose a pattern and an environment for the problem you actually have.
Compare approachesA beginner route, a local setup and an extension challenge.
Open the how-to guideNo. Start with the default example, read the trace and compare the two implementations. The tutorial introduces the code after you have seen the result.
No. Examples use invented records and simulated downstream work. Each lab keeps its own transient environment; resetting it stops the experiment.
The browser runs the same Go engine compiled to WebAssembly inside a dedicated worker. Goroutines run concurrently, but this browser target is not a multicore throughput benchmark. A harness cleans up the deliberately blocked example after recording it. The native download includes an HTTP adapter and Go tests.
The original lesson and application source are MIT-licensed. Third-party runtimes retain their own licenses. Download the package and follow GETTING_STARTED before changing it.