package exec

Import Path
	os/exec (on golang.org and go.dev)

Dependency Relation
	imports 12 packages, and imported by 8 packages

Involved Source Files
	d-> exec.go
	    exec_unix.go
	    lp_unix.go

Exported Type Names

type Cmd (struct) Cmd represents an external command being prepared or run. A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods. Args []string Dir string Env []string ExtraFiles []*os.File Path string Process *os.Process ProcessState *os.ProcessState Stderr io.Writer Stdin io.Reader Stdout io.Writer SysProcAttr *syscall.SysProcAttr (*T) CombinedOutput() ([]byte, error) (*T) Output() ([]byte, error) (*T) Run() error (*T) Start() error (*T) StderrPipe() (io.ReadCloser, error) (*T) StdinPipe() (io.WriteCloser, error) (*T) StdoutPipe() (io.ReadCloser, error) (*T) String() string (*T) Wait() error *T : expvar.Var *T : fmt.Stringer func Command(name string, arg ...string) *Cmd func CommandContext(ctx context.Context, name string, arg ...string) *Cmd func internal/testenv.CleanCmdEnv(cmd *Cmd) *Cmd func internal/testenv.CleanCmdEnv(cmd *Cmd) *Cmd
type Error (struct) Error is returned by LookPath when it fails to classify a file as an executable. Err error Name string (*T) Error() string (*T) Unwrap() error *T : error
type ExitError (struct) An ExitError reports an unsuccessful exit by a command. ProcessState *os.ProcessState Stderr []byte (*T) Error() string (T) ExitCode() int (T) Exited() bool (T) Pid() int (T) String() string (T) Success() bool (T) Sys() interface{} (T) SysUsage() interface{} (T) SystemTime() time.Duration (T) UserTime() time.Duration *T : error T : expvar.Var T : fmt.Stringer
Exported Values
func Command(name string, arg ...string) *Cmd 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[0] 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.
func CommandContext(ctx context.Context, name string, arg ...string) *Cmd 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.
func LookPath(file string) (string, error) 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.