vinchent
c5582275e7
Use a go routine for the work logic. Here sleep and append to string. Inside the go routine, select for ctx.Done(). If happens, just stop and return. In the outside function, select for ctx.Done() too. If it happens, that means the work logic has not finished before canceled. |
||
---|---|---|
.. | ||
context_test.go | ||
context.go |