尝试从Go应用启动终端时出现“退出状态1” [重复]

This question already has an answer here:

I have quite a simple Go app called myApp that is supposed to launch a new Terminal window on macOS:

package main

import (
    "fmt"
    "os/exec"
)

func main() {
    err := exec.Command("open", "-a", "Terminal", "/Users/ns/go/").Run()
    if err != nil {
        fmt.Println(err)
    }
}

However, when I run the app I get the following output:

ns:~/go/src/github.com/nevadascout/myApp $ go install && myApp
exit status 1

If I run the command (open -a Terminal /Users/ns/go/) in the terminal manually, it works.
What am I missing?

</div>

From the docs:

Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. The package behaves more like C's "exec" family of functions. To expand glob patterns, either call the shell directly, taking care to escape any dangerous input, or use the path/filepath package's Glob function. To expand environment variables, use package os's ExpandEnv.

So you need to run bash -c command and pass above command as argument. Something like this:

exec.Command("bash", "-c", "open", "-a", "Terminal", "~/go/").Run()

For windows you should use cmd /C. Example:

exec.Command("cmd", "/C", ...)