我试图在golang中禁用Keep-Alive连接,但是没有清晰的说明如何做到这一点。
package main
import (
"net/http"
"github.com/julienschmidt/httprouter"
"fmt"
)
func helloworld(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "Hello, World!")
}
func main() {
router := httprouter.New()
router.GET("/", helloworld)
fmt.Println("Running :-)")
http.Server.SetKeepAlivesEnabled(false)
log.Fatal(http.ListenAndServe(":3030", router))
}
有人能解决这个问题吗?