Documentation
¶
Overview ¶
Package exec wraps the os/exec package. It facilitates testing by use of the sub-packge fake.
Example
var buf bytes.Buffer c := Command("echo", "bob") c.SetStdout(&buf) err := c.Run()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command func(cmd string, args ...string) Cmd = NewCommand
Command is a variable that normally points to NewCommand. It is a variable so tests can redirect calls to a fake.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd interface { SetStdout(io.Writer) // Redirect standard output to the writer SetStderr(io.Writer) // Redirect standard error to the writer SetStdin(io.Reader) // Redirect standard in to the reader Run() error // Operates the same as os/exec/Cmd.Run }
A Cmd is an interface representing a command to run.
func NewCommand ¶
NewCommand returns a Cmd that can run the supplied command. NewCommand sets up stdout and stderr to go to os.Stdout and os.Stderr. SetStdout and SetStderr are used to change where to send the output.
Most programs should use exec.Command rather than exec.NewCommand.
Click to show internal directories.
Click to hide internal directories.