go-imap icon indicating copy to clipboard operation
go-imap copied to clipboard

Allow using context.Context instead of a channel

Open mpldr opened this issue 2 years ago • 0 comments

It would be great to have the possibility to use a context instead of a channel in function calls, since they pretty much do exactly what the stop channel is supposed to do as well. With network libraries it's more common to use a context which also allows for easy implementation of timeouts and cancellation that's passed through multiple child contexts.

  • breaking the API can be avoided by adding a *Ctx function which just accepts context.Context instead of a stop channel
  • code duplication can be avoided by just calling the *Ctx-function from the channel-function

mpldr avatar Jun 25 '22 14:06 mpldr