【发布时间】:2016-11-17 10:14:07
【问题描述】:
我正在尝试使用 go 执行命令。
executableCommand := strings.Split("git commit -m 'hello world'", " ")
executeCommand(executableCommand[0], executableCommand[1:]...)
cmd := exec.Command(command, args...)
但这是我得到的
error: pathspec 'world"' did not match any file(s) known to git.
exit status 1
这是因为-m 仅获得'hello 而不是'hello world',因为命令行是使用" " 拆分的。
有什么办法让它发挥作用吗?
【问题讨论】:
标签: git go command-line command