While testing some code with something like this:
// ch := make(chan error)
for {
    select {
      case <- ch:
           println("here")
    }
}
I notice that if I don't add a default the code blocks:
for {
    select {
       case <- ch:
            println("here")
       default:
    }
}
In case that the block is required, could't be better then just use range, something like:
for {
    for _ = range <- ch {
        println("here")
    }
}
Or is there any difference/advantage of using select over range for this case ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With