Go语言获取本地IP地址

冷絮 ·
你这把一堆都弄出来了把? ```golang func getLocalIP() net.IP { raddr, err1 := net.ResolveIPAddr("ip4:icmp", "220.181.38.148") laddr, err2 := net.ResolveIPAddr("ip4:icmp", "") con, err3 := net.DialIP("ip4:icmp", laddr, raddr) if err1 != nil || err2 != nil || err3 != nil { fmt.Println(err1, err2, err3) return nil } defer con.Close() return net.ParseIP(con.LocalAddr().String()) } } ```
#6