Documentation ¶
Overview ¶
Package pexec provides a mechanism for invoking a program executable with a varying set of arguments.
Below is an example showing how you might invoke the `echo` executable with arguments;
package main import ( "os" "github.com/paketo-buildpacks/packit/pexec" ) func main() { echo := pexec.NewExecutable("echo") err := echo.Execute(pexec.Execution{ Args: []string{"hello from pexec"}, Stdout: os.Stdout, }) if err != nil { panic(err) } // Output: hello from pexec }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executable ¶
type Executable struct {
// contains filtered or unexported fields
}
Executable represents an executable on the $PATH.
func NewExecutable ¶
func NewExecutable(name string) Executable
NewExecutable returns an instance of an Executable given the name of that executable. When given simply a name, the execuable will be looked up on the $PATH before execution. Alternatively, when given a path, the executable will use that path to invoke the executable file directly.
func (Executable) Execute ¶
func (e Executable) Execute(execution Execution) error
Execute invokes the executable with a set of Execution arguments.
type Execution ¶
type Execution struct { // Args is a list of the arguments to be passed to the executable. Args []string // Dir is the path to a directory from with the executable should be invoked. // If Dir is not set, the current working directory will be used. Dir string // Env is the set of environment variables that make up the environment for // the execution. If Env is not set, the existing os.Environ value will be // used. Env []string // Stdout is where the output of stdout will be written during the execution. Stdout io.Writer // Stderr is where the output of stderr will be written during the execution. Stderr io.Writer }
Execution is the set of configurable options for a given execution of the executable.