Note that you don't need to clean up a channel. The GC will automatically free the channel when there is no more reference to it. The only reason to close a channel is to send a signal to the other goroutines that you are done and there is no more data to send. Other than that, you don't need to clean up a channel.
In addition, you still need to have some rudimentary design in your head. Having multiple goroutines closing a single channel is a bad idea. Have one goroutine become the owner of the channel and it alone can close the channel. A similar principle applies when sharing data concurrently. You need to be aware of *who owns what* at all times. On Tuesday, March 19, 2019 at 12:18:24 PM UTC+7, Andrey Tcherepanov wrote: > > > Thank you all very much for the discussion and suggestions. I decided to > take a dive and opened proposal under > https://github.com/golang/go/issues/30916 > > Any suggestions on improvements are welcome, but please keep in mind that > I am not trying to solve my CURRENT problem at hand (it is solved, already > in production, and it is not very important how un-elegant it is) - I am > trying to express a need for less panic-y "it is done" mechanism for > general use. > > -- Andrey > > > On Wednesday, March 13, 2019 at 12:40:30 AM UTC-6, Andrey Tcherepanov > wrote: >> >> Hello fellow Go devs, >> >> I have a question that probably is a bit weird and obvious, but here we go >> ... >> > -- 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. For more options, visit https://groups.google.com/d/optout.