我使用https://github.com/gin-gonic/gin 来编写一个 http 服务,但是当我部署它的时候,它一直部署在 tcp6上(根据 netstat):
r := gin.Default()
//none of these are working , It keeps being listed on tcp6
r.Run(":8080")
r.Run("*:8080")
r.Run("0.0.0.0:8080")
我使用https://github.com/gin-gonic/gin 来编写一个 http 服务,但是当我部署它的时候,它一直部署在 tcp6上(根据 netstat):
r := gin.Default()
//none of these are working , It keeps being listed on tcp6
r.Run(":8080")
r.Run("*:8080")
r.Run("0.0.0.0:8080")
The documentation states
Run attaches the router to a http.Server and starts listening and serving HTTP requests. It is a shortcut for http.ListenAndServe(addr, router)
You can start the server directly using an http.Server
the same way the http
package does in ListenAndServe
server := &http.Server{Handler: r}
l, err := net.Listen("tcp4", addr)
if err != nil {
log.Fatal(err)
}
err = server.Serve(l)
// ...