Go · Stage 10 – Concurrency · Lesson 57 of 64

Goroutines

Start one function concurrently with the go keyword.

Go code

func say() { fmt.Println("Hello") }

go say()
time.Sleep(10 * time.Millisecond)
Line-by-line explanation
  1. Say is defined.
  2. The go keyword starts it as a goroutine.
  3. Sleep keeps main alive briefly for this demonstration.
Expected output
Hello

Real programs should coordinate completion rather than guessing with Sleep.