package main
import (
"fmt"
"net"
)
func main() {
interfaces, err := net.Interfaces()
if err != nil {
panic("Error:" + err.Error())
}
for _, inter := range interfaces {
fmt.Println(inter.Name)
fmt.Println(inter.Index)
fmt.Println(inter.HardwareAddr)
}
}
转载于:https://my.oschina.net/lengxugz/blog/477814