英文:
command execution on MacOSx in golang
问题
我有一个简单的Go语言程序,用于在MacOSx上启动一个应用程序。
package main
import (
"io"
"log"
"os/exec"
)
func main() {
out1, err1 := exec.Command("/usr/bin/open", "-a", "calculator").Output()
log.Printf("output is err", err1)
log.Printf("output is out", out1)
}
我期望在执行后它能启动计算器应用程序,但是我收到以下错误信息:
2017/04/26 16:01:26 output is err%!(EXTRA *os.PathError=fork/exec /usr/bin/open : no such file or directory) 2017/04/26 16:01:26 output is out%!(EXTRA []uint8=[])
我正在尝试在OSx 10.11上运行它。
英文:
I have a simple golang program to start an application in MacOSx.
package main
import (
"io"
"log"
"os/exec"
)
func main() {
out1,err1 := exec.Command("/usr/bin/open ", " -a", "calcultor").Output()
log.Printf(" output is err ", err1)
log.Printf(" output is err ", out1)
}
I expect it to start application in calculator after execution but i receive following errors
> 2017/04/26 16:01:26 output is err%!(EXTRA *os.PathError=fork/exec
> /usr/bin/open : no such file or directory) 2017/04/26 16:01:26 output
> is out%!(EXTRA []uint8=[])
I am trying it on OSx 10.11.
答案1
得分: 1
有一个拼写错误 - "calcultor" 应该是 "calculator"。
英文:
There's a spelling mistake - "calcultor" should be "calculator".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论