Nonsense. Closing channels is a generic means of broadcasting to all listeners a state change.
To say that only one goroutine should ever initiate such a change is a needless and pointless restriction. On Tue, Dec 20, 2022 at 2:40 AM Jan Mercl <0xj...@gmail.com> wrote: > 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/CAPNEFAbwQM51gmN8Pq%3D4hOs4cdKv%3DHzHhUAjeG-YOgs5fcmbAw%40mail.gmail.com.