gpt4 book ai didi

go - http.Server 中的端口 ":http"是什么意思?

转载 作者:IT王子 更新时间:2023-10-29 01:18:30 24 4
gpt4 key购买 nike

我在阅读文档中 http.Server 的类型声明时发现了这一点。

type Server struct {
Addr string // TCP address to listen on, ":http" if empty
// more...
}

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

":http" 是什么意思?

最佳答案

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

关于go - http.Server 中的端口 ":http"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31555845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com