Commit cf383700 authored by szh's avatar szh

优化获取本地ip流程

parent 20a5e9cf
...@@ -30,6 +30,9 @@ func Broadcast() { ...@@ -30,6 +30,9 @@ func Broadcast() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
if len(ips) == 0 {
panic("no ip found")
}
ip := ips[0] ip := ips[0]
// 这里设置发送者的IP地址,自己查看一下自己的IP自行设定 // 这里设置发送者的IP地址,自己查看一下自己的IP自行设定
...@@ -54,6 +57,9 @@ func Broadcast() { ...@@ -54,6 +57,9 @@ func Broadcast() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
if len(ips) == 0 {
panic("no ip found")
}
ip = ips[0] ip = ips[0]
if runningAddr != nil && runningAddr.IP.String() != ip.IP.String() { if runningAddr != nil && runningAddr.IP.String() != ip.IP.String() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment