【发布时间】:2018-09-28 18:31:27
【问题描述】:
我想在 Golang 中复制以下 subprocess.run 函数调用。正确的方法是什么?
subprocess.run(['kinit', username], input=password.encode())
到目前为止,我已经弄清楚如何使用exec.Command 来运行外部命令,但让我感到困惑的是将字符串作为输入传递给该命令的STDIN。 Python 的subprocess.run 有一个方便的input 参数来处理这个问题,我怎样才能在Golang 中获得类似的结果?
【问题讨论】:
标签: go subprocess pipe exec piping