On Fri, Feb 17, 2017 at 1:34 PM, <so.qu...@gmail.com> wrote: > I'm not sure how to implement and use the Done function and its returned > channel for contexts. > https://golang.org/pkg/context/#Context > > The comments say to refer to https://blog.golang.org/pipelines, but I didn't > see any example there. > > Can you provide an example of how to implement a context that supports > cancellation with Done?
You aren't really expected to write your own implementations of the Context interface. You are expected to start with context.Background and modify that context using WithCancel, WithTimeout, WithValue, etc. For example, if you write ctx, cancel := ctx.WithCancel(context.Background()) Then ctx.Done() will be closed when you call cancel(). Ian -- 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.