Closed
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
Go master HEAD 8d0c105
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
What did you do?
package main
import (
"log"
"fmt"
"time"
"net"
"net/http"
)
type server3 struct {
http.Server
}
func (s *server3) Serve(l net.Listener) error {
fmt.Println("Serving")
time.Sleep(time.Second)
return s.Server.Serve(l)
}
// naming is a bitch
func (s *server3) Shutdown() {
fmt.Println("Closing")
s.Close()
}
func main() {
srv := &server3{}
srvEnd := make(chan error)
for {
l, err := net.Listen("tcp","")
if err != nil {
log.Fatal(err)
}
go func() {
err := srv.Serve(l)
srvEnd <- err
}()
time.Sleep(time.Second)
srv.Shutdown()
fmt.Println("Close done")
err = <- srvEnd
fmt.Println(err)
}
}
What did you expect to see?
Serving
Closing
Close done
^C
What did you see instead?
Serving
Closing
^C