pexec

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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/cloudfoundry/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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL