With the following select statement I want to ensure that some none-blocking function is only executed one by one:
select {
case <-available:
default:
fmt.Println("busy")
return
}
go func() {
defer func() { available <- true }()
doSomethingOneByOne()
}()
Currently I'm using bool
as a channel type and it works as expected.
What I don't like is that using bool
suggests that it matters if the value is true
or false
. But actually it doesn't matter in this case. In my opinion this makes understanding the code a bit harder because it is misleading.
Is there a convention for which type to use when the value doesn't matter?