零号智能

  • Python
  • 部署
  • go
  • VPS
  • 运维
  • 生活琐事
  • html
零号智能
Fantasia's blog npc0.com.
  1. 首页
  2. go
  3. 正文

go os/exec 弄了一上午被坑

2021年1月9日 4072点热度 0人点赞 0条评论
switch runtime.GOOS {
case "windows":
   hms := t.Format("15:04:05")
   _ = exec.Command("cmd", "/C", "time", hms).Run()
   date := t.Format("2006-01-02")
   _ = exec.Command("cmd", "/C", "date", date).Run()
default:
   date := t.Format("2006-01-02 01:01:01")
   _ = exec.Command("bash", "-c", "date -s " + date).Run()
}

请注意大小写 "cmd", ”/C“ cmd小写, /C大写

详情请看:https://www.xspdf.com/resolution/58572436.html

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2021年5月22日

vpc

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2021 npc0.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备19157245号-1

粤公网安备 44030702002746号