Keep in mind that this article is from 2015 and a few things have changed, such as context being in the standard library (which matters for the imports) and the fact that you can now do HTTP requests with a context too which would simply the HTTP example.
I actually find this to be a good resource overall, it's mostly the HTTP part that needs updating. So instead of doing a regular http.Request you can now do an http.RequestWithContext(ctx, ...) and do the cancellation stuff without needing to set up an channel yourself to receive errors and such.
Keep in mind that this article is from 2015 and a few things have changed, such as context being in the standard library (which matters for the imports) and the fact that you can now do HTTP requests with a context too which would simply the HTTP example.
Thanks, didn't realise it was so old. Do you have a more up to date link you'd recommend instead?
I actually find this to be a good resource overall, it's mostly the HTTP part that needs updating. So instead of doing a regular http.Request you can now do an http.RequestWithContext(ctx, ...) and do the cancellation stuff without needing to set up an channel yourself to receive errors and such.