# go-concurrency-exercises: 6 Go concurrency puzzles where the test tells you when you're right

> go-concurrency-exercises is a hands-on Go workshop with 6 numbered exercises covering patterns from crawler rate-limiting to graceful signal handling, each verified by running go test. You edit main.go and the test file is frozen, so there is no way to cheat the check.

**loong/go-concurrency-exercises** — Hands on exercises with real-life examples to study and practice Go concurrency patterns. Test-cases are provided to verify your answers.

- Repository: https://github.com/loong/go-concurrency-exercises
- Stars: 2,009 · Forks: 578
- Language: Go
- License: NOASSERTION
- Published: 2026-10-11 · Updated: 2026-10-11 · Language: en
- Canonical page: https://hysenlabs.com/projects/loong-go-concurrency-exercises

## 6 exercises where you write the solution before you can check whether it works

Go concurrency documentation is not scarce. Goroutines, channels, select, mutex and sync primitives are covered across the official tour, the specification and many blog posts. What is harder to find is a set of concrete problems you solve yourself with a test that catches bugs without telling you the answer.

go-concurrency-exercises provides 6 numbered exercises in the repository, each in its own directory, where you write working Go concurrency code and a test tells you whether it's correct. The exercises cover patterns that appear in real services: rate-limiting a web crawler, coordinating producers and consumers, catching a race condition in a cache, enforcing time limits for free-tier users, handling a SIGINT gracefully, and cleaning up inactive sessions to prevent memory overflow.

The exercises are numbered 0 through 5, but the README does not describe them as arranged by difficulty. Each exercise gives you a failing or incomplete main.go file, and your job is to make the tests pass. No hint system and no walkthrough exist in the repository beyond the problem description in each exercise directory.

## Only main.go is editable; the test files are frozen to prevent shortcutting

Every exercise enforces a single rule: edit only the main.go file in that exercise's directory. All other files, including any test files, are off limits. The README names this rule explicitly, and the per-exercise AGENTS.md files repeat the same constraint for AI coding agents.

The frozen test file is what makes the exercise function correctly as a practice problem. If the test file were editable, a learner could remove the assertions and pass the tests without writing the actual concurrency logic. By locking main.go as the only editable surface, the repository forces you to write the actual concurrency logic rather than working around it.

The README notes that some exercises include a `*_test.go` file, using the phrase "if you find" rather than "every exercise has." That phrasing indicates that not all 6 exercises have test files, which means some of them have no automated way to check a solution. For those, correctness depends on running the code and observing behavior directly.

## Clone the repository, navigate to an exercise directory, and run go test

No package installation or build step is required beyond having a Go toolchain. The go.mod file at the repository root requires go 1.19 at minimum and sets the module path as github.com/loong/go-concurrency-exercises.

The repository has no documented clone or setup command, but once cloned you work inside individual exercise directories. Move into an exercise directory, edit main.go to add your solution, and then verify it:

```bash
go test
```

That single command runs the test file in the current directory. A passing run means your solution satisfies the test assertions. A failing run reports which assertions failed, giving you a signal of what still needs fixing without explaining why the fix works.

For anyone who gets stuck, the README points to the Go community Discord at discord.com/invite/golang and the Gophers Slack at invite.slack.golangbridge.org. Both are general Go community resources, not exercise-specific channels. The README says to find the maintainer via `@loong` if neither community channel yields a response.

## The 6 exercises and the concurrency problems each one targets

Exercise 0 covers crawl limiting, a pattern that throttles concurrent HTTP requests to avoid overwhelming a target server. Exercise 1 covers the producer-consumer pattern, where 1 goroutine generates work and others consume it. Exercise 2 is a race condition in a caching scenario, designed to expose how unsynchronized reads and writes to shared state produce unpredictable results.

Exercise 3 covers service-time limiting for free-tier users, a pattern that cancels a long-running operation after a deadline. Exercise 4 is graceful SIGINT killing, which involves catching an operating system interrupt signal and giving in-flight work a chance to finish before exiting. Exercise 5 covers session cleanup, where inactive entries in a map or similar structure are removed on a schedule to keep memory bounded.

All 6 exercises model patterns from production Go services rather than contrived toy problems. A developer who finishes the exercises will have handled the exact patterns that show up in service-to-service HTTP clients, worker pools and background maintenance goroutines.

## AGENTS.md, llms.txt and exercises.json let AI coding tools work through the exercises too

go-concurrency-exercises has been explicitly set up for AI coding agents alongside human learners. 4 artifacts support that use case: AGENTS.md at the repository root describes how to coach a learner, which files are frozen, and how to run tests, following the AGENTS.md convention from agents.md. llms.txt provides a curated index for crawlers and chat agents, following the llmstxt.org convention. exercises.json is a machine-readable catalog of every challenge. A .agents/skills/ directory holds 2 on-demand skills named take-exercise and maintain-exercises.

Each individual exercise directory also has its own AGENTS.md file. The top-level AGENTS.md includes the instruction: "Please do not paste full solutions into main.go unless the learner asks." That instruction is specific: paste a full solution into main.go only when the learner explicitly asks.

A CLAUDE.md file also appears at the repository root, though its contents are not documented in the README.

## No explanations, no hint system, and no solutions: what the repository does not provide

go-concurrency-exercises is a problem set, not a tutorial. It gives you a concurrency problem and a test that fails if your solution is wrong, and it stops there. No written explanation of why the correct pattern works, no progressive hints, and no reference solutions appear anywhere in the repository.

A developer who does not yet have the conceptual background will not get it here. This repository assumes the reading has already happened. A developer who does not know what a sync.Mutex or sync.WaitGroup does will not learn that here. The README is direct about this: the Go community has plenty of resources for reading about concurrency, and this repository exists specifically for the doing part that follows the reading.

The 6 exercises are also a fixed set. There is no mechanism for generating new exercises or for adjusting difficulty. A developer who wants to practice a specific pattern beyond the 6 covered, such as a fan-out, a semaphore, or a context cancellation chain, will not find it here and cannot extend the set without modifying the repository directly.

## Community channels for help and what the repository does not document for contributors

The README lists 2 community resources: the Go community Discord at discord.com/invite/golang and the Gophers Slack at invite.slack.golangbridge.org. Both are general Go community resources rather than channels dedicated to these exercises specifically, and the README instructs the learner to find the maintainer via `@loong` if no one in those communities can help.

No CONTRIBUTING.md appears in the top-level repository entries, which means there is no documented process for submitting new exercises or reporting issues through GitHub. The repository has no GitHub releases, so there is no versioned history to track.

The licence is the Do What The Fuck You Want To Public License, Version 2, which GitHub classifies as "Other." The full terms in the README read: "You just DO WHAT THE FUCK YOU WANT TO." Using, forking or redistributing the exercises carries no restriction under that licence.

## Conclusion

go-concurrency-exercises suits a Go developer who already reads the language comfortably and wants to move from reading about goroutines and channels to writing code that a test verifies. Skip it if you need explanations of why a pattern works, since the exercises provide no written guidance beyond the problem statement. The 6 exercises cover specific patterns, so a developer who has already worked through producer-consumer or race-condition scenarios will not find new ground here. Before starting, check whether each exercise directory you plan to work on has a `*_test.go` file, because the README indicates not every exercise has one.

## FAQ

### How do I use go-concurrency-exercises?

Clone the repository, move into one of the 6 numbered exercise directories (0-5), edit only the main.go file with your solution, and run go test to verify it. The test file in each directory is frozen and checks your implementation.

### What Go version does go-concurrency-exercises require?

The go.mod file at the repository root specifies go 1.19 as the minimum required version.

### What concurrency patterns does go-concurrency-exercises cover?

The 6 exercises cover crawler rate-limiting, producer-consumer coordination, race conditions in a cache, service-time limiting for free-tier users, graceful SIGINT handling, and session cleanup to prevent memory overflow.

### Can AI coding agents use go-concurrency-exercises?

Yes. The repository explicitly supports AI agents through AGENTS.md files at the root and in each exercise directory, a machine-readable exercises.json catalog, an llms.txt index, and 2 on-demand skills in .agents/skills/. The AGENTS.md instructs agents not to paste full solutions unless the learner requests it.

### Does go-concurrency-exercises provide answers or explanations?

No. The repository provides only the problem descriptions and test files. Conceptual explanations and reference solutions are not included.

## Sources

- [Issues](https://github.com/loong/go-concurrency-exercises/issues)
- [loong/go-concurrency-exercises on GitHub](https://github.com/loong/go-concurrency-exercises)
- [README](https://github.com/loong/go-concurrency-exercises/blob/main/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/loong-go-concurrency-exercises
