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

Closed
gdi63 opened this issue Aug 13, 2019 · 1 comment

Comments

@gdi63
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) {

@smasher164

This comment has been minimized.

Copy link
Member

@smasher164 smasher164 commented Aug 13, 2019

Yes, it matches. See https://golang.org/ref/spec#Method_values.
Here is a playground example to demonstrate this behavior: https://play.golang.org/p/yHJtcrG4H0d.
For questions about Go, see https://golang.org/wiki/Questions.

@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
Projects
None yet
2 participants
You can’t perform that action at this time.