Hi,
Are there any common patterns that standard and 3rd party library functions use to implement cancelling a context passed to it? I have looked at the source of exec.CommandContext and it starts the process and spawns a goroutine that kills the process when ctx.Done() is closed. That looks simple enough.
It seems to me that the key to implementing cancellation enabled function is to look at specific points inside the function where ctx.Done() is checked for. As an example, if I want to create a cancellable function that reads lines from a file, would select'ing on ctx.Done() be a good place?
Thanks.