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: document that Server.Serve expects a hashable net.Listener (as a map key) #25487

Closed
jdef opened this issue May 22, 2018 · 8 comments

Comments

Projects
None yet
7 participants
@jdef
Copy link

commented May 22, 2018

What version of Go are you using (go version)?

1.10

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vagrant/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vagrant/workspace-dss"
GORACE=""
GOROOT="/usr/local/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build230598238=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I implemented net.Listener with a struct that defined a func() field. I passed this struct to http.Server.Serve. The code compiled just fine and panicked at run-time because my listener implementation couldn't be used as a hash key (see trackListener in the http package).

What did you expect to see?

A working http.Server. Or else some documentation that clearly states the constraints for the kinds of listeners usable with http.Server.

What did you see instead?

Panic at run-time.

@meirf

This comment has been minimized.

Copy link
Contributor

commented May 22, 2018

@jdef Thanks for your report. This is probably enough information to reproduce your issue, but it would be helpful if you had a snippet in the form of a https://play.golang.org link to save us time in reproducing and in guaranteeing we fix the exact issue.

@artyom

This comment has been minimized.

Copy link
Contributor

commented May 22, 2018

Duplicate of #24812 ?

@jdef

This comment has been minimized.

Copy link
Author

commented May 22, 2018

@AlekSi

This comment has been minimized.

Copy link
Contributor

commented May 22, 2018

@jdef Can you please close it then?

@meirf

This comment has been minimized.

Copy link
Contributor

commented May 22, 2018

@odeke-em odeke-em changed the title http: server Listeners are required to be hashable (as map keys), but it's not documented net/http: document that Server.Serve expects a hashable net.Listener (as a map key) May 22, 2018

@odeke-em

This comment has been minimized.

Copy link
Member

commented May 22, 2018

Great point @meirf! Might you or anyone else here be interested in sending a CL?

@artyom

This comment has been minimized.

Copy link
Contributor

commented May 23, 2018

@meirf, @odeke-em looks like the linked issue already has this fixed, so we don’t need to change documentation.

@meirf

This comment has been minimized.

Copy link
Contributor

commented May 24, 2018

@artyom Yes, looks like a fix for this was merged as shown in the linked issue. Sorry for misleading.

@jdef A fix for this has been merged, though not yet in an official release.

@odeke-em please close when you have a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.