端口":http"在http.Server中的含义是什么?

425*_*esp 6 go

我正在阅读http.Server文档中的类型声明,我遇到了这个.

type Server struct {
    Addr string // TCP address to listen on, ":http" if empty
    // more...
}
Run Code Online (Sandbox Code Playgroud)

如果你调用srv.ListenAndServe()并且srv.Addr是一个空字符串,那么ListenAndServe将传递":http"net.Listen(http/server.go).

什么":http"意思?

Rey*_*les 8

有时端口有别名.http你可以在这里看到更多的名字:http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml