Programming/golang

golang mac address 얻기

구차니 2022. 9. 28. 12:03

"net" 패키지의 Interfaces() 람수를 이용하여 얻어올 수 있다.

[링크 : https://socketloop.com/tutorials/golang-get-local-ip-and-mac-address]

[링크 : https://stackoverflow.com/questions/44859156/get-permanent-mac-address]

 

HardwareAddr은 MAC address, Name에는 lo, eth 같은 장치식별자가 들어간다.

type Interface struct {
Index        int          // positive integer that starts at one, zero is never used
MTU          int          // maximum transmission unit
Name         string       // e.g., "en0", "lo0", "eth0.100"
HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form
Flags        Flags        // e.g., FlagUp, FlagLoopback, FlagMulticast
}

[링크 : https://pkg.go.dev/net#Interface]