This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // getMacAddr gets the MAC hardware | |
| // address of the host machine | |
| func getMacAddr() (addr string) { | |
| interfaces, err := net.Interfaces() | |
| if err == nil { | |
| for _, i := range interfaces { | |
| if i.Flags&net.FlagUp != 0 && bytes.Compare(i.HardwareAddr, nil) != 0 { | |
| // Don't use random as we have a real address | |
| addr = i.HardwareAddr.String() | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "net" | |
| ) | |
| func main() { | |
| fmt.Printf("MAC: %16.16X\n", macUint64()) |