These operations would help but they're not unique to errors, even though they most often arise in that context.
Since this proposal relies on some form of generics to implement As
, why not make the interface and both operations generic so we can Is
or As
a wrapped io.Reader
just as easily?
When wrapping a possibly already wrapped reader you could see if it was already buffered and choose to use the minimum buffering needed to implement your wrapper's functionality, knowing that the underlying buffering will take care of the rest. It would also be useful for debugging since you could print out the entirety of the nesting (that wouldn't use As or Is, just the interface, though).
I'm sure there are use-cases for http.ResponseWriter as well since it can have lots of extra methods which makes it very hard to wrap as it is now.