Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: transport.go: strange assignment func(pc *persistConn) cancelRequest(error) to func(error) #33634

gdi63 opened this issue Aug 13, 2019 · 1 comment


Copy link

@gdi63 gdi63 commented Aug 13, 2019

Does it really work? Does func(error) type match to method of persistConn

type Transport struct {
reqCanceler map[*Request]func(error)

func (t *Transport) replaceReqCanceler(r *Request, fn func(error)) bool {
t.reqCanceler[r] = fn

func (pc *persistConn) cancelRequest(err error) {

func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err error) {
if !pc.t.replaceReqCanceler(req.Request, pc.cancelRequest) {


This comment has been minimized.

Copy link

@smasher164 smasher164 commented Aug 13, 2019

Yes, it matches. See
Here is a playground example to demonstrate this behavior:
For questions about Go, see

@smasher164 smasher164 closed this Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.