BTW currently a private channel with length of 1 is being used and the other side must call a function to get the result (with a timeout). This way the second signal about closing the channel is not a problem. And we see this inside the standard library too, like in the time channel of a time.Ticker which will not get closed by the Stop() functions to prevent an incorrect notification.
On Monday, October 30, 2017 at 11:22:16 AM UTC+3:30, dc0d wrote: > > Problem: After the completion of some task, the task issuer should be > informed about the completion/failure of the task - like by using some > struct { Result Result, Err error }. > > Question: Which mechanism is preferred: using channels or callbacks? > > Why the question: IMHO channels are the answer but there is this problem > with channels that after sending the result to the channel, if we close it, > there would be another signal which notifies the other side about the > channel be closed (in _, ok := <-rsultChan; ok will be false). > -- 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.