. [# v4 F* a0 Y/ c8 } 解决方案: 2 O2 z4 t8 h* {6 _4 o
您需要遍历所有网络接口 6 k% o! ^) v' x9 Z. L; l7 i[code]ifaces,err := net.Interfaces()// handle errfor _,i := range ifaces addrs,err := i.Addrs() / handle err for _,addr := range addrs var ip net.IP switch v := addr.(type) case *net.IPNet: ip = v.IP case *net.IPAddr: ip = v.IP process IP address code]