# README
xip
ip
、port
辅助函数
- 获取除回环地址外的本机所有地址
- 判断某个地址是否是内网地址
- 获取空闲端口
例子
port, err := GetFreePort()
xpanic.WhenError(err)
fmt.Println("free port:", port)
localIP := GetLocalIP()
fmt.Printf("%s is intranet? %v\n", localIP, IsIntranet(localIP))
Output:
free port: 55304
10.0.48.24 is intranet? true
# Functions
GetFreePort asks the kernel for a free open port that is ready to use.
GetLocalIP returns the non loopback local IP of the host 该接口在 POD 中可能会获取到空的 local IP.
IsIntranet 是否是内网地址.
IsValidIP4 是否是合法的 ip4 地址.
LocalIpv4Addrs scan all ip addresses with loopback excluded.