Documentation
¶
Overview ¶
Package process wraps os/exec with a fluent builder modelled on Laravel's Process facade.
Compared to os/exec, the wrapper:
- returns a typed Result with ExitCode, Stdout, Stderr, Duration;
- accepts a context.Context for cancellation and timeouts;
- never starts a shell — the first argument is the program, the rest are exact argv entries (no string-split surprises, no injection from interpolated values).
Usage:
r, err := process.Command("git", "rev-parse", "HEAD").Run(ctx)
if err != nil { return err }
fmt.Println(r.Stdout)
// timeout + working directory + extra env
_, _ = process.Command("npm", "test").
Dir("/srv/app").
Env("CI", "1").
Timeout(2 * time.Minute).
Run(ctx)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTimeout = errors.New("process: timeout")
ErrTimeout is returned when the process is killed because the configured timeout (or the caller's context deadline) elapsed.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd is an immutable builder. Each setter returns a clone so chains compose safely:
base := process.Command("git").Dir("/repo")
a := base.Args("status", "--short") // doesn't mutate base
func Command ¶
Command builds a process invocation. The first argument is the program; remaining arguments are passed as separate argv entries (no shell interpretation).
func (*Cmd) AppendArgs ¶
AppendArgs adds to the existing argument list.
Click to show internal directories.
Click to hide internal directories.