1 Star 0 Fork 1

flyiot/flylibs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
action.go 661 Bytes
一键复制 编辑 原始数据 按行查看 历史
flyrainning 提交于 2023-03-03 16:52 +08:00 . u
package FlyOS
import (
"os/exec"
"runtime"
)
// 重启
func Reboot() (string, error) {
if runtime.GOOS == "window" {
cmd := exec.Command("shutdown", "/r", "/f")
output, err := cmd.Output()
return string(output), err
} else {
cmd := exec.Command("/bin/bash", "-c", "reboot")
output, err := cmd.Output()
return string(output), err
}
}
// 关机
func Poweroff() (string, error) {
if runtime.GOOS == "window" {
cmd := exec.Command("shutdown", "/p", "/f")
output, err := cmd.Output()
return string(output), err
} else {
cmd := exec.Command("/bin/bash", "-c", "poweroff")
output, err := cmd.Output()
return string(output), err
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/flyiot/flylibs.git
git@gitee.com:flyiot/flylibs.git
flyiot
flylibs
flylibs
b9c81f1c9857

搜索帮助