### 获取对外ip地址
func GetOutBoundIP()(ip string, err error) {
conn, err := net.Dial("udp", "8.8.8.8:53")
if err != nil {
fmt.Println(err)
return
}
localAddr := conn.LocalAddr().(*net.UDPAddr)
fmt.Println(localAddr.String())
ip = strings.Split(localAddr.String(), ":")[0]
return ip,err
}
go语言获取对外ip地址
最新推荐文章于 2025-02-24 08:30:00 发布

5万+

被折叠的 条评论
为什么被折叠?



