I have this piece of code.
func Start() bool {
for {
if checkSomthingIsTrue() {
if err := doSomthing(); err != nil {
continue
}
}
select {
case <-ctx.Done():
return true
}
}
}
How to make the above function non blocking without using default:
case.
reason to not use default case is because its eating up 100% CPU always.
Answer: I have used time.Ticker to throttle Thanks