exec

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OSLinux is the alias of Linux
	OSLinux = "linux"
	// OSDarwin is the alias of Darwin
	OSDarwin = "darwin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultExecer added in v0.0.68

type DefaultExecer struct {
}

DefaultExecer is a wrapper for the OS exec

func (DefaultExecer) Arch added in v0.0.73

func (e DefaultExecer) Arch() string

Arch returns the os arch

func (DefaultExecer) Command added in v0.0.73

func (e DefaultExecer) Command(name string, arg ...string) ([]byte, error)

Command is the wrapper of os/exec.Command

func (DefaultExecer) LookPath added in v0.0.68

func (e DefaultExecer) LookPath(file string) (string, error)

LookPath is the wrapper of os/exec.LookPath

func (DefaultExecer) OS added in v0.0.73

func (e DefaultExecer) OS() string

OS returns the os name

func (DefaultExecer) RunCommand added in v0.0.73

func (e DefaultExecer) RunCommand(name string, arg ...string) error

RunCommand runs a command

func (DefaultExecer) RunCommandAndReturn added in v0.0.73

func (e DefaultExecer) RunCommandAndReturn(name, dir string, args ...string) (result string, err error)

RunCommandAndReturn runs a command, then returns the output

func (DefaultExecer) RunCommandInDir added in v0.0.73

func (e DefaultExecer) RunCommandInDir(name, dir string, args ...string) error

RunCommandInDir runs a command

func (DefaultExecer) RunCommandWithBuffer added in v0.0.73

func (e DefaultExecer) RunCommandWithBuffer(name, dir string, stdout, stderr *bytes.Buffer, args ...string) error

RunCommandWithBuffer runs a command with buffer stdout and stderr could be nil

func (DefaultExecer) RunCommandWithIO added in v0.0.73

func (e DefaultExecer) RunCommandWithIO(name, dir string, stdout, stderr io.Writer, args ...string) (err error)

RunCommandWithIO runs a command with given IO

func (DefaultExecer) RunCommandWithSudo added in v0.0.73

func (e DefaultExecer) RunCommandWithSudo(name string, args ...string) (err error)

RunCommandWithSudo runs a command with sudo

func (DefaultExecer) SystemCall added in v0.0.74

func (e DefaultExecer) SystemCall(name string, argv []string, envv []string) (err error)

SystemCall is the wrapper of syscall.Exec

type Execer added in v0.0.68

type Execer interface {
	LookPath(string) (string, error)
	Command(name string, arg ...string) ([]byte, error)
	RunCommand(name string, arg ...string) (err error)
	RunCommandInDir(name, dir string, args ...string) error
	RunCommandAndReturn(name, dir string, args ...string) (result string, err error)
	RunCommandWithSudo(name string, args ...string) (err error)
	RunCommandWithBuffer(name, dir string, stdout, stderr *bytes.Buffer, args ...string) error
	RunCommandWithIO(name, dir string, stdout, stderr io.Writer, args ...string) (err error)
	SystemCall(name string, argv []string, envv []string) (err error)
	OS() string
	Arch() string
}

Execer is an interface for OS-related operations

type FakeExecer added in v0.0.68

type FakeExecer struct {
	ExpectError         error
	ExpectLookPathError error
	ExpectOutput        string
	ExpectOS            string
	ExpectArch          string
}

FakeExecer is for the unit test purposes

func (FakeExecer) Arch added in v0.0.73

func (f FakeExecer) Arch() string

Arch returns the os arch

func (FakeExecer) Command added in v0.0.73

func (f FakeExecer) Command(name string, arg ...string) ([]byte, error)

Command is a fake method

func (FakeExecer) LookPath added in v0.0.68

func (f FakeExecer) LookPath(path string) (string, error)

LookPath is a fake method

func (FakeExecer) OS added in v0.0.73

func (f FakeExecer) OS() string

OS returns the os name

func (FakeExecer) RunCommand added in v0.0.73

func (f FakeExecer) RunCommand(name string, arg ...string) error

RunCommand runs a command

func (FakeExecer) RunCommandAndReturn added in v0.0.73

func (f FakeExecer) RunCommandAndReturn(name, dir string, args ...string) (result string, err error)

RunCommandAndReturn is a fake method

func (FakeExecer) RunCommandInDir added in v0.0.73

func (f FakeExecer) RunCommandInDir(name, dir string, args ...string) error

RunCommandInDir is a fake method

func (FakeExecer) RunCommandWithBuffer added in v0.0.73

func (f FakeExecer) RunCommandWithBuffer(name, dir string, stdout, stderr *bytes.Buffer, args ...string) error

RunCommandWithBuffer is a fake method

func (FakeExecer) RunCommandWithIO added in v0.0.73

func (f FakeExecer) RunCommandWithIO(name, dir string, stdout, stderr io.Writer, args ...string) error

RunCommandWithIO is a fake method

func (FakeExecer) RunCommandWithSudo added in v0.0.73

func (f FakeExecer) RunCommandWithSudo(name string, args ...string) (err error)

RunCommandWithSudo is a fake method

func (FakeExecer) SystemCall added in v0.0.74

func (f FakeExecer) SystemCall(name string, argv []string, envv []string) error

SystemCall is a fake method

Jump to

Keyboard shortcuts

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