25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started โ†’

Interactive Go ยท Lesson

Select & sync

When you’re juggling several channels, select waits on all of them at once and runs whichever is ready first:

select {
case msg := <-orders:
    fmt.Println("order:", msg)
case <-quit:
    fmt.Println("standing down")
}

The sync package covers the cases where channels are overkill โ€” sync.WaitGroup (which you’ve met) for waiting, and sync.Mutex (Lock/Unlock) to protect shared state from concurrent writes.

Your Quest

Use a select statement to receive a value from the ready channel and print it. (It’s a buffered channel that already holds "go!", so the receive is ready immediately.)

Expected output:

go!

Hint

select {
case msg := <-ready:
    fmt.Println(msg)
}

Additional Scrolls of Wisdom