golang,如何执行需要用户输入的命令
发布于 2021-02-01 10:41:37
我想从Go执行perforce命令行“ p4”以执行登录工作。“ p4登录”要求用户输入密码。
如何在Go中运行需要用户输入的程序?
以下代码不起作用。
err = exec.Command(p4cmd, "login").Run()
if err != nil {
log.Fatal(err)
}
关注者
0
被浏览
99
1 个回答
-
// Stdin specifies the process's standard input. If Stdin is // nil, the process reads from the null device (os.DevNull). Stdin io.Reader
在执行命令之前,设置命令的Stdin字段。