在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kavu/go_reuseport开源软件地址:https://github.com/kavu/go_reuseport开源编程语言:Go 97.4%开源软件介绍:GO_REUSEPORTGO_REUSEPORT is a little expirement to create a For now, Darwin and Linux (from 3.9) systems are supported. I'll be pleased if you'll test other systems and tell me the results. documentation on godoc.org. Examplepackage main
import (
"fmt"
"html"
"net/http"
"os"
"runtime"
"github.com/kavu/go_reuseport"
)
func main() {
listener, err := reuseport.Listen("tcp", "localhost:8881")
if err != nil {
panic(err)
}
defer listener.Close()
server := &http.Server{}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println(os.Getgid())
fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path))
})
panic(server.Serve(listener))
} Now you can run several instances of this tiny server without ThanksInspired by Artur Siekielski post about |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论