exec

package
v0.0.0-...-c87aca2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakeCommand

func FakeCommand(t *testing.T) (*mock.MockCmd, *gomock.Controller)

FakeCommand is backed by a mock and used for testing

func FakeCommandContext

func FakeCommandContext(t *testing.T) (*mock.MockCmd, *gomock.Controller)

FakeCommandContext is backed by a mock and used for testing

Types

type Cmd

type Cmd interface {
	CombinedOutput() ([]byte, error)
	Credential(*syscall.Credential)
	Output() ([]byte, error)
	Run() error
	Start() error
	StderrPipe() (io.ReadCloser, error)
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.ReadCloser, error)
	Wait() error
}

Cmd represents an external command being prepared or run.

A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods.

func Command

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.

func CommandContext

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.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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