On Tue, Dec 20, 2022 at 9:21 AM Jason E. Aten <j.e.a...@gmail.com> wrote:
> Shutting down goroutines quickly was needed so often that I wrote a package > to help me with it. it is called idem, short for idempotent. > > It uses the idea of an idempotent Close of a channel to signal that the > goroutine should stop. This is because Go will panic if > close a channel more than once (i.e. you wish to stop a goroutine from more > than one place). This is a design flaw in channels, > but we can work around it by using a mutex. I disagree with it being a design flaw. Quite the opposite, IMO. Closing a channel more than once reveals a design flaw in the respective program and panicking is about the only safe thing to do in that situation. Working around this safety feature should be discouraged. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-UxSkA6ATXsmXyE9NZtXiOLBFpV8FMRK8y9t829Hu02dQ%40mail.gmail.com.