There's actually been a fair amount of conversation on this topic
lately. Most recently it came up in this thread:
https://groups.google.com/forum/#!searchin/golang-nuts/context|sort:date/golang-nuts/Lqoj5bNQxzg/5LUEYGHAGQAJ
My biggest worry about making it implicit is that it becomes hard to
tell what APIs actually respect cancellation via context. The context
package was introduced at a point when the language was already fairly
mature, so much of the standard library and ecosystem doesn't accept
context parameters, thus providing no (standard) way of canceling those
operations (though some packages have their own ad-hoc mechanisms).
I think if you were going to make the context implicit, to keep things
sane you'd also have to somehow ensure cancellation is "always"
respected. I know of two languages that provide this sort of mechanism
-- Erlang and Haskell -- but they do this by means of asynchronous
exceptions, which besides having their own pitfalls in the abstract,
would completely break essentially all of the resource cleanup code
written in Go today, by introducing race conditions, not to mention
fundamentally change how error handling has to work.
People have pointed out real problems with the current situation, but I
haven't seen a good solution yet.
-Ian
Quoting David Suarez (2019-01-24 12:02:15)
> its use to only those areas it is really needed?�
>
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [1]
golang-nuts...@googlegroups.com.
> For more options, visit [2]
https://groups.google.com/d/optout.
>
> Verweise
>
> 1. mailto:
golang-nuts...@googlegroups.com
> 2.
https://groups.google.com/d/optout