Skip to content

net/http: document that Server.Serve expects a hashable net.Listener (as a map key) #25487

Closed
@jdef

Description

@jdef

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions