Goroutines

A goroutine is a lightweight unit of concurrent execution managed by the Go runtime. A program starts a goroutine by placing the go keyword before a function or method call.

Minimal example

go
func main() {
    done := make(chan bool)
    go func() {
        done <- true
    }()
    <-done
}

Learn this concept

Lesson 1.13 · Goroutines, WaitGroup and the race detector

Used in exercises

Exercise 1.14 · Limiter interface and a FixedWindow implementation Exercise 1.15 · Table-driven tests with a fake clock, plus one race test Exercise 5.13 · Hub broadcast and claim race tests Exercise 8.2 · Stock reservation service
Prerequisite conceptsGo functions