Command: Invoke program
Invoking program
Invoking external program and Shell command
.InvokeShell(shellCmdLine)
and .UseShell(shellPath)
can be used for launching a Shell command (just like ls -la
), the last one could specify which concrete shell (bash, or zsh?) will be used, or by using a default one.
.InvokeProc(program)
can be used for launching a external executable file.
As in macOS, .InvokeProc("say 'hello world'")
would execute say
command and play voice with hello world
text.
A program
means it should not be a shell command. If you're really needing that, trying with bash -c echo "hello"
.
We commonly launch a GUI app with it.
Difinitions
The examples/demo/
showes howto using invokeXXX
, in cmd/invoke.go
:
Run
The result with the example app is,
额外的话题
How is this guide?
Edit on GitHub
Last updated on