package main
import (
"fmt"
"math/rand"
"net"
"time"
)
func main() {
ppp := struct{ Mac string }{""}
if ppp.Mac == "" {
rand.Seed(time.Now().UnixNano()) // 使用当前时间为随机数生成器设置种子
mac := make(net.HardwareAddr, 6)
_, _ = rand.Read(mac)
fmt.Println(mac)
// 修改前三项为您所需的格式
mac[0] = 0x00
// 生成第二段和第三段为纯数字
mac[1] = byte(rand.Intn(10))*16 + byte(rand.Intn(10))
mac[2] = byte(rand.Intn(10))*16 + byte(rand.Intn(10))
macString := fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5])
ppp.Mac = macString
}
fmt.Println("Generated MAC address:", ppp.Mac)
}