Background: I was writing an HTTP proxy using net.http which supports both HTTP/1 and HTTP/2. I need to detect errors and do correct things according to RFC (
It turns out that net.http has its own bundled copy of x/net/http2 (
https://golang.org/src/net/http/h2_bundle.go) with nothing exported. So I cannot do things like
var h2err http2.StreamError
if errors.As(err, &h2err) { // dealing with errors
it will never match because the actual error is `http.http2StreamError` which is not exported. In this case, what's the correct way to detect http2 specific errors?