Teiva Harsanyi
Sep 28, 2022

--

If I may, here's a solution that 1. prevent your goroutine from waking up every 10 seconds and 2. is much more reactive when the signal to stop sleeping is sent (almost immediate compared to having to wait in the worst case 9.99 seconds):

https://go.dev/play/p/s0zK915DhYm

--

--

Teiva Harsanyi
Teiva Harsanyi

Written by Teiva Harsanyi

Software Engineer @Google | The Coder Cafe newsletter (https://thecoder.cafe) | 📖 100 Go Mistakes author | 改善

Responses (1)