package main
import(
"fmt"
"net"
)
func main(){
addrs, err := net.InterfaceAddrs()
if err != nil{
fmt.Println(err)
return
}
for _, value := range addrs{
if ipnet, ok := value.(*net.IPNet); ok && !ipnet.IP.IsLoopback(){
if ipnet.IP.To4() != nil{
fmt.Println(ipnet.IP.String())
}
}
}
}
|
请发表评论