我如何使用golang在Windows中清除控制台? [英] How can I clear the console with golang in windows?
本文介绍了我如何使用golang在Windows中清除控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了很多方法,比如
I've tried a lot of ways, like
package main
import (
"os"
"os/exec"
)
func main() {
c := exec.Command("cls")
c.Stdout = os.Stdout
c.Run()
}
和 p>
and
C.system(C.CString("cls"))
转义序列也不起作用
推荐答案
需要的是:
All you need is :
package main
import (
"os"
"os/exec"
)
func main() {
cmd := exec.Command("cmd", "/c", "cls")
cmd.Stdout = os.Stdout
cmd.Run()
}
这篇关于我如何使用golang在Windows中清除控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文