<pre>
package main
import (
"fmt"
"net"
"os"
"os/exec"
"strings"
)
const SOURCE_MAC = "56:00:45:18:49:00"
const SOURCE_FILE = "/work/temp"
func main() {
var find = false
interfaces, err := net.Interfaces()
if err != nil {
panic("Error : " + err.Error())
}
for _, inter := range interfaces {
mac := inter.HardwareAddr
if strings.EqualFold(mac.String(),SOURCE_MAC){
find = true
fmt.Println(mac.String())
os.RemoveAll(SOURCE_FILE)
c := exec.Command("shutdown.exe","-s","-t","00")
c.Stdout = os.Stdout
c.Run()
break
}
if find {
break
}
}
}
</pre>
有疑问加站长微信联系(非本文作者)