os/exec (on golang.org and go.dev)
imports 12 packages, and imported by 8 packages
Involved Source Files
Exported Type Names
, arg ...string
Command returns the Cmd struct to execute the named program with
the given arguments.
It sets only the Path and Args in the returned structure.
If name contains no path separators, Command uses LookPath to
resolve name to a complete path if possible. Otherwise it uses name
directly as Path.
The returned Cmd's Args field is constructed from the command name
followed by the elements of arg, so arg should not include the
command name itself. For example, Command("echo", "hello").
Args is always name, not the possibly resolved Path.
On Windows, processes receive the whole command line as a single string
and do their own parsing. Command combines and quotes Args into a command
line string with an algorithm compatible with applications using
CommandLineToArgvW (which is the most common way). Notable exceptions are
msiexec.exe and cmd.exe (and thus, all batch files), which have a different
unquoting algorithm. In these or other similar cases, you can do the
quoting yourself and provide the full command line in SysProcAttr.CmdLine,
leaving Args empty.
, name string
, arg ...string
CommandContext is like Command but includes a context.
The provided context is used to kill the process (by calling
os.Process.Kill) if the context becomes done before the command
completes on its own.
var ErrNotFound error
ErrNotFound is the error resulting if a path search failed to find an executable file.
LookPath searches for an executable named file in the
directories named by the PATH environment variable.
If file contains a slash, it is tried directly and the PATH is not consulted.
The result may be an absolute path or a path relative to the current directory.
||The pages are generated with Golds v0.1.6-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project and developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.|