github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/internal/pkg/helper/mac.go (about) 1 package helper 2 3 import ( 4 "fmt" 5 "math/rand" 6 "strings" 7 ) 8 9 func GenerateMac() (ret string) { 10 buf := make([]byte, 6) 11 12 rand.Read(buf) 13 14 buf[0] |= 2 15 ret = fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]) 16 17 ret = strings.ToUpper(ret) 18 19 return 20 }