ConcurrencyGoroutines & WaitGroups
All courses

Lightweight concurrent tasks

go f() starts a goroutine. Use sync.WaitGroup to wait for completion. Pass loop variables into goroutines as parameters — classic closure capture bug otherwise.

Quirk: Goroutine order is nondeterministic — output order may vary. That is normal, not a bug.

Output
Press Run to execute your code.