Skip to content

Process v0.2.0: reusable runners and worker cleanup

Latest

Choose a tag to compare

@cmilesio cmilesio released this 03 Dec 08:07

Run commands with reusable settings, test them without launching subprocesses, and stop their workers when the work ends.

go get github.com/goforj/process

Configure once, run again

Reuse a working directory, environment, input, and timeout across commands. Each invocation gets fresh execution state.

runner := process.NewRunner().
	Timeout(30 * time.Second).
	WithProcessTree()

result, err := runner.Run(ctx, "go", "test", "./...")

Clean up the whole command

  • Opt into descendant cleanup on Linux, macOS, and Windows with WithProcessTree().
  • Cancel commands, enforce timeouts, or terminate background work without leaving contained workers running.
  • Give Unix workers a grace period to finish cleanup, then stop remaining processes.

Test application code without real commands

Accept process.Executor and use processtest.Fake to queue results and inspect requested commands. Unexpected calls fail instead of launching a subprocess.

More control, clearer examples

  • Bound inherited output-pipe draining with WaitDelay.
  • Distinguish idle timeouts, total timeouts, and unsuccessful exits.
  • Browse 94 runnable examples, including error handling that preserves deferred cleanup.

Upgrading

Existing command APIs and defaults remain available. Descendant cleanup is opt-in. Go 1.27 or newer is required.

The accidental v1.0.0 and corrective v1.0.1 tags are retracted. If you pinned either version, explicitly switch your requirement to v0.2.0.

See examples and API usage and execution behavior for platform details.