Goroutines — lightweight threads managed by Go runtime.
Key points:
1// Start goroutine2go func() {3 fmt.Println("Hello from goroutine")4}()56// Wait for goroutine7var wg sync.WaitGroup8wg.Add(1)9go func() {10 defer wg.Done()11 fmt.Println("Working...")12}()13wg.Wait()
Comparison with threads: