select lets a goroutine wait on multiple channel operations simultaneously, proceeding with whichever is ready first. It's like a switch but for channels — essential for coordinating concurrent operations, timeouts, and cancellation.
Basic select — wait on multiple channels
{
msg1 := <-ch1:
fmt.Println(, msg1)
msg2 := <-ch2:
fmt.Println(, msg2)
ch3 <- :
fmt.Println()
}
