2 Star 2 Fork 6

王布衣 / gox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cpu_linux.go 648 Bytes
一键复制 编辑 原始数据 按行查看 历史
//go:build linux
package devices
import (
"net"
)
func macAddress() (PhysicalID string, err error) {
// 获取本机的MAC地址
interfaces, err := net.Interfaces()
if err != nil {
return defaultPhysicalID, err
}
PhysicalID = defaultPhysicalID
for _, inter := range interfaces {
if inter.Name == "en0" || inter.Name == "eth0" {
//fmt.Println(inter.Name)
mac := inter.HardwareAddr //获取本机MAC地址
//fmt.Println("MAC = ", mac)
PhysicalID = mac.String()
break
}
}
return
}
// CpuPhysicalID linux用第一块网卡的mac地址代替
func CpuPhysicalID() (PhysicalID string, err error) {
return macAddress()
}
Go
1
https://gitee.com/quant1x/gox.git
git@gitee.com:quant1x/gox.git
quant1x
gox
gox
v1.21.1

搜索帮助

53164aa7 5694891 3bd8fe86 5694891