Goroutine
A goroutine is a lightweight function execution unit managed by the Go runtime that runs concurrently with other program activity.
Go in Practice, Second Edition
A goroutine is a lightweight Go-managed execution context that runs a function concurrently with other program activity.
- How it is used
- Runs background tasks and independent server or file-processing work without making the initiating function wait.
- How deep it goes
- Explains launch syntax, lifetime, waiting, panic handling, and shutdown patterns, while leaving detailed concurrency theory and runtime internals aside.
- Examples
- Uses a timed input echo, parallel Gzip compression, and connection-handling servers to show concurrent work.
- What you can do after
- Build it from scratch with `go`, `sync.WaitGroup`, and channels to start work, await completion, and arrange safe shutdown.
Read how Go in Practice, Second Edition explains goroutine →
Learn Concurrent Programming with Go
A goroutine is a lightweight Go execution construct that represents a concurrent activity managed by the Go runtime.
- How it is used
- Models independent concurrent activities so applications can pursue work without waiting at every function call.
- How deep it goes
- Defines creation and runtime placement, then demonstrates execution order, shared memory, and channel-based result collection without prescribing a required implementation.
- Examples
- Uses sleeping work calls, a shared countdown, concurrent web-page letter counting, file-search exercises, and parallel factor calculations.
- What you can do after
- Apply it via Go’s go keyword to run functions concurrently and use channels to collect background results.
Read how Learn Concurrent Programming with Go explains goroutine →
Learn Go with Pocket-Sized Projects
A goroutine is a lightweight independently executing function managed by the Go runtime.
- How it is used
- Runs independent work in background functions, including concurrent cache tests and maze-branch exploration.
- How deep it goes
- Explains launching, completion, communication, and practical hazards, but stops short of a detailed comparison with operating-system threads.
- Examples
- Uses two background printing functions, concurrent writes to one cache key, and branching exploration in a maze solver.
- What you can do after
- Build it from scratch: launch independent Go functions, wait for their completion, and assess whether concurrency suits the task.
Read how Learn Go with Pocket-Sized Projects explains goroutine →
Go in Action, Second Edition
A lightweight Go execution unit that runs a function concurrently with the rest of a program.
- How it is used
- Runs independent work concurrently to keep network-facing programs responsive without managing OS threads directly.
- How deep it goes
- Explains launch syntax and runtime scheduling, then develops completion, cancellation, and fan-out/fan-in coordination through an HTTP handler.
- Examples
- Uses RSS feed fetching, premature program exit, and an HTTP endpoint that aggregates articles and errors from concurrent fetches.
- What you can do after
- Build it from scratch: launch and coordinate concurrent feed fetches, collect their results, and avoid abandoning unfinished work.
100 Go Mistakes and How to Avoid Them
A goroutine is a lightweight independently executing function managed by the Go runtime.
- How it is used
- Uses goroutines to expose concurrency mistakes involving shutdown, loop variables, synchronization, and parallel-work size.
- How deep it goes
- Works through code and observable effects for leaks, closure capture, and merge-sort performance without detailing runtime scheduling.
- Examples
- Contrasts leaking channel receivers and watcher shutdown options, then uses loop output and merge-sort benchmarks to show other pitfalls.
- What you can do after
- Diagnose/debug goroutine leaks and loop-variable surprises, and evaluate when parallel work warrants goroutine overhead.
Read how 100 Go Mistakes and How to Avoid Them explains goroutine →
Build and Orchestrator in Go (From Scratch)
A goroutine is a lightweight concurrent execution unit managed by the Go runtime.
- How it is used
- Separates background worker operations from API request handling so task processing can continue concurrently.
- How deep it goes
- Demonstrates `go` calls, continuous loops, and anonymous functions, while deferring goroutine implementation details.
- Examples
- Uses a queue-polling task loop, concurrent statistics collection and API serving, and a periodic manager-update loop.
- What you can do after
- Apply it to run worker task processing, statistics collection, and API serving concurrently.
Read how Build and Orchestrator in Go (From Scratch) explains goroutine →
Go by Example
A goroutine is a lightweight Go execution unit that runs a function concurrently with other goroutines.
- How it is used
- Enables concurrent tasks in crawlers, request dispatchers, distributed programs, and HTTP servers.
- How deep it goes
- Defines goroutines, demonstrates go calls, and outlines scheduler behavior while deferring full scheduler internals.
- Examples
- Demonstrates concurrent crawl calls, dispatcher workers and a monitor, and HTTP handlers running per request.
- What you can do after
- Apply goroutines to launch concurrent work and coordinate completion through channels.
Related concepts
- Goused by · Go is a statically typed, compiled, garbage-collected programming language with built-in support for concurrency.
- go keywordused by · The Go go keyword starts a function or method call as a goroutine, allowing it to execute concurrently with the caller.
- threadalternative to · A thread is an independently schedulable sequence or context of execution within a program or process.
- channeluses · A channel is a medium, mechanism, or pathway through which information or messages are conveyed between participants or endpoints.
- concurrencyused by · Concurrency is the structuring or execution of multiple computational activities so their progress overlaps in time, whether or not they run simultaneously.
- fan-outused by · Fan-out is a pattern in which one input or operation distributes work, messages, or tasks across multiple downstream branches or processing units.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






