I have a blocking operation in a 3rd party library that I don't control. It could potentially go forever. So I want to set a timeout on it. The obvious way is to wrap it with a channel and a goroutine and then select on the result with
time.After. However, the problem is the goroutine running the blocking operation could potentially go forever.
Here is an example to illustrate this http://repl.it/90o
Is there a way to cancel a goroutine or have it garbage collected?