oktopus/backend/services/controller/internal/utils/utils.go
2023-03-20 11:19:02 -03:00

22 lines
367 B
Go

package utils
import (
"net"
)
// Get interfaces MACs, and the first interface MAC is gonna be used as mqtt clientId
func GetMacAddr() ([]string, error) {
ifas, err := net.Interfaces()
if err != nil {
return nil, err
}
var as []string
for _, ifa := range ifas {
a := ifa.HardwareAddr.String()
if a != "" {
as = append(as, a)
}
}
return as, nil
}