Mahdi.Kh
November 23, 2026
What concurrency is and how it differs from parallelism, how Go approaches it with goroutines and channels, a map of the whole series, and the tools that catch concurrency bugs.
Open almost any Go service and you will find several things going on at once: a server answering hundreds of requests, each request calling a database and a couple of other services, a background job cleaning up old data, a ticker flushing metrics every few seconds. Go makes starting all of this almost too easy: one keyword, go, and a function runs on its own. Making those pieces cooperate, stop on time and never trample each other's data is where the real work is.
That work is what this series is about. Over sixteen parts we go from the first goroutine to the patterns you meet in real code: pipelines, worker pools, pub/sub, cancellation with context, circuit breakers, rate limiters and actors. Each part explains one idea with a picture, gives you programs you can run and edit right on the page, shows the mistakes people actually make, and says when something simpler would do. This first part sets the stage: what concurrency is, how Go thinks about it, how the series is laid out, and which tools to keep at hand.
Concurrency means a program is made of independent pieces that can make progress without waiting for each other. Parallelism means some of those pieces run at literally the same instant, on different CPU cores. The first is about how you structure the program; the second is about the machine it happens to run on. Rob Pike put it in two sentences: "Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once."
A kitchen makes the difference easy to see. One cook with three dishes on the go is concurrent: while the soup simmers, the cook chops the salad and checks the oven. Nothing happens at the same instant, but nothing sits waiting either. Add a second cook and two dishes get attention at the same moment: that is parallelism. The recipes did not change; the number of cooks did.
The diagram above shows the same thing with three goroutines, A, B and C. On one core they take turns, and all three make progress. On two cores, two of them really run at the same time and the work finishes sooner. The code is identical in both rows: Go's runtime decides how many goroutines run in parallel, normally one per core (GOMAXPROCS). You write concurrent code, and you get parallelism for free when the hardware has it. And a program that mostly waits, on the network or the disk, gains from concurrency even on a single core, because while one goroutine waits, another works.
Go's concurrency rests on two things built into the language. A goroutine is a function running independently, started with the go keyword; it begins with a stack of a few kilobytes, so a program can have hundreds of thousands of them, and the runtime spreads them over a handful of operating-system threads. A channel is a typed pipe that goroutines use to hand values to each other, and handing a value over also synchronizes them: a send on an unbuffered channel does not finish until another goroutine receives it.
Both come from an idea Tony Hoare described in 1978, communicating sequential processes (CSP): a program built from sequential pieces that share nothing and talk only by passing messages. Go does not force that style (it also has sync.Mutex and friends, and several parts of this series use them), but it encourages it with a proverb you will see quoted everywhere:
Don't communicate by sharing memory; share memory by communicating.
In practice it means: instead of several goroutines reaching into the same variable and guarding it with a lock, let one goroutine own the data and have the others send it values or requests. You will meet this idea again and again, from the first channel to the actors of the last part. When a plain lock is simpler, Go is happy with that too; the series shows both and says when each one fits.
Here is the whole idea in a few lines. Three slow "services" are called once one after another and once all at the same time, and the program measures both:
The sequential loop waits for each call before starting the next, so it takes the sum of the three delays, about 600 ms. The concurrent version starts each call in its own goroutine, every goroutine sends its result into the results channel, and main receives three times. Now the program takes as long as the slowest call, about 300 ms, and the results arrive in the order the calls finish, not the order they were started:
Every program in this series with a Run button under it is complete and runs right on the page, with Go 1.24 and the standard library. A few things help you get the most out of them:
time.Sleep of a few hundred milliseconds at most.To use the race detector from the next section, or a package outside the standard library, copy the program to your own machine.
The sixteen parts come in five groups. Each part stands on its own and links back to what it relies on, but read in order they build on each other.
If concurrency in Go is new to you, read the three basics first and in order; everything after them assumes them. Then take Pipeline, Worker Pool and Context: between them they cover most of the concurrent code you will write at work. After that, go through the rest group by group, and keep the actor model for last, since it brings many of the earlier ideas together.
If you already write concurrent Go, jump straight to the part you need. Each one opens with the problem it solves, so a paragraph is enough to tell whether it is the one you are after.
Concurrency bugs hide. A program can run correctly a thousand times and fail on the next run, or only on a busier machine. These tools help you find them before your users do.
A data race happens when two goroutines touch the same variable at the same time and at least one of them writes. Go ships a detector for it: add -race to go test, go run or go build, and the program reports every race it actually runs into, with the stack traces of both goroutines.
It only sees races that happen during that run, so it is most useful with tests that exercise the concurrent paths. Make go test -race ./... part of your CI. It makes a program several times slower and hungrier for memory, so keep it for tests and development, not for the binary you ship.
go vet catches some concurrency mistakes before anything runs: a sync.Mutex or sync.WaitGroup copied by value (the copylocks check), a cancel function from context.WithCancel that is never called (lostcancel), and misuse of sync/atomic. go test runs only a few of its checks on its own, so run go vet ./... as well.
Tests of concurrent code have habits of their own. Wait for goroutines with channels or a sync.WaitGroup, never with a time.Sleep that is "probably long enough". Give every wait a timeout with select and time.After, so a deadlock fails the test instead of hanging it, with go test -timeout as the last line of defence. Run the tests many times, go test -race -count=100, to shake out rare interleavings. Newer Go versions also add testing/synctest, which runs goroutines against a fake clock so time-based code can be tested without real waiting. If tests in Go are new to you, start with Unit Testing from our Golang basics series.
The quietest bug of all is a goroutine leak: a goroutine blocked forever on a channel nobody will use again. It costs nothing at first and a lot of memory later. Compare runtime.NumGoroutine() before and after the code under test, or use Uber's goleak package in your tests; in a running service, look at the goroutine profile from net/http/pprof, where thousands of goroutines parked on the same line are a leak. Almost every part of this series shows how its pattern can leak and how to prevent it.
-race, keep go vet clean, and treat every goroutine you start as something that must be able to stop.In the next part we start with the smallest building block of all: the goroutine, what it really is, and how to start one, wait for it and stop it.
Next part: Goroutine Basics | Concurrency in Go