You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
350 B
22 lines
350 B
package gomac
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
func GetMacAddrs() (macAddrs []string) {
|
|
netInterfaces, err := net.Interfaces()
|
|
if err != nil {
|
|
return macAddrs
|
|
}
|
|
for _, netInterface := range netInterfaces {
|
|
macAddr := netInterface.HardwareAddr.String()
|
|
if len(macAddr) == 0 {
|
|
continue
|
|
}
|
|
|
|
macAddrs = append(macAddrs, macAddr)
|
|
}
|
|
return macAddrs
|
|
}
|