I have a default cause in a select statement that I want to do nothing, just continue, but leaving the line blank stops anything in the statement from happening
select {
case quit_status := <-quit:
if quit_status == true {
fmt.Printf("********************* GOROUTINE [%d] Received QUIT MSG\n", id)
return
}
default:
fmt.Printf("GOROUTINE [%d] step: %d, NO QUIT MSG\n", id, i)
}
The
defaultcase in aselectstatement is intended to provide non-blocking I/O for channel reads and writes. The code in thedefaultcase is executed whenever none of the channels in any of the cases are ready to be read/written to.So in your case, the
defaultblock is executed if the quit channel has nothing to say.You can simply remove the default case and it will block on the
quit_status := <-quitcase until a value is available inquit.. which is probably what you are after in this instance.If you want to immediately continue executing code after the select statement, you should run this select statement in a separate goroutine: