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

cmdrun

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cmdrun runs host commands (ip, nft, mkfs.ext4) behind a small interface so that callers can be tested with a fake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Name  string
	Args  []string
	Stdin string
}

Call is one recorded invocation of a Fake.

func (Call) String

func (c Call) String() string

String renders the call as a shell-like line.

type Exec

type Exec struct{}

Exec runs real commands.

func (Exec) Run

func (Exec) Run(ctx context.Context, stdin io.Reader, name string, args ...string) ([]byte, error)

Run implements Runner. A non-zero exit becomes an error carrying the command line and its output.

type Fake

type Fake struct {
	Calls  []Call
	Handle func(Call) ([]byte, error)
}

Fake records calls and answers them with Handle (nil means success).

func (*Fake) Lines

func (f *Fake) Lines() []string

Lines returns the recorded calls as strings.

func (*Fake) Run

func (f *Fake) Run(_ context.Context, stdin io.Reader, name string, args ...string) ([]byte, error)

Run implements Runner.

type Runner

type Runner interface {
	Run(ctx context.Context, stdin io.Reader, name string, args ...string) ([]byte, error)
}

Runner runs a command to completion and returns its combined output.

Jump to

Keyboard shortcuts

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