github.com/go-eden/common@v0.1.15-0.20210617133546-059099253264/enet/net_utils.go (about) 1 package enet 2 3 import "net" 4 5 // MacAddrs return all net-interface's hardware addresses. 6 func MacAddrs() (macAddrs []string) { 7 netInterfaces, err := net.Interfaces() 8 if err != nil { 9 return macAddrs 10 } 11 for _, netInterface := range netInterfaces { 12 macAddr := netInterface.HardwareAddr.String() 13 if len(macAddr) == 0 { 14 continue 15 } 16 macAddrs = append(macAddrs, macAddr) 17 } 18 return macAddrs 19 }