4
我试图用go执行一个命令。Golang:使用它的参数执行一个命令
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'
,因为在命令行中使用" "
被分割。
任何想法,使其工作?