Help us shape the future of Go! Take the 2026 Go Developer Survey

execx

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package execx centralizes process execution behind mockable entry points.

Historically each cmd package declared its own `var execCommand = exec.Command` / `lookPath = exec.LookPath`, scattering ~100 direct os/exec call sites. New code should use this package; existing call sites migrate incrementally.

Index

Constants

This section is empty.

Variables

View Source
var (
	Command        = exec.Command
	CommandContext = exec.CommandContext
	LookPath       = exec.LookPath
)

Mockable function variables. Tests may stub these.

Functions

This section is empty.

Types

type Cmd

type Cmd = exec.Cmd

Cmd aliases exec.Cmd so callers can drop the os/exec import entirely.

type DefaultRunner

type DefaultRunner struct{}

DefaultRunner is the production Runner.

func (DefaultRunner) CommandContext

func (DefaultRunner) CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext creates an exec.Cmd bound to ctx.

func (DefaultRunner) LookPath

func (DefaultRunner) LookPath(file string) (string, error)

LookPath resolves a binary on PATH.

type ExitError

type ExitError = exec.ExitError

ExitError aliases exec.ExitError for exit-code inspection without os/exec.

type Runner

type Runner interface {
	CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
	LookPath(file string) (string, error)
}

Runner is a minimal interface for running external processes. DefaultRunner delegates to os/exec; tests provide fakes.

var Default Runner = DefaultRunner{}

Default is the production Runner instance.

Jump to

Keyboard shortcuts

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