▲ 16 ▼ Context should go away in Go 2
As usual, when a new blog post comes out on blog.golang.org, I’m all eager to read it as soon as possible. The most recent one, Contributors Summit, is a nice write-up on the issues that the Go contributors have been talking about. While reading it, I stumbled upon a sentence that made me write this post. Here is is:
Register to comment or vote on this story
This does seem a little biased because the author is not writing server software, which is really the intended use of context. It does feel like cancellation is something that would be better built into goroutines though, rather than tacked on to every api.
Context may still be required in web apps though in order to thread request specific data through various levels of handlers/middleware.
Even if you don't agree with it, this is an interesting take on uses of context and how it could complicate simple interfaces across the standard library.
I agree with the premise that having context deal with both cancellation and context is a problem, and that should stop. It does indeed cause context to migrate into places it has no real business being, aside from the cancellation side-effect. That should be its own thing. However, I don't think context as a whole needs to go away, but its responsibilities should be split.