structure of select is something similar to switch statement, it has multiple nodes waiting for a channel to return something and if it does then a block of code associated with it run, we generally use Aftermethod form time module as default to prevent waiting forever for channels to return and select statement is specially designed to work with concurrent go routines

syntax :

select {
case channelOperation:
    // Code to handle the case when channelOperation1 can proceed
case ch1 <- value1:
    // Code to handle successful send to ch1
case msg2 := <-ch2:
    // Code to handle message from ch2
// ... (more cases)
case <-time.After(5 * time.Second):
    // Timeout case: Code to handle timeout
default:
    // Code to handle the default case if no other case is immediately ready
}

remember here channelOperation’s can be both writing to a channel and reading from a channel