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

common

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTasksCore

func ExecuteTasksCore(
	ctx context.Context,
	tasks []Task,
	maxProcs int,
	timeout time.Duration,
	failFast bool,
	onResult func(Result) error,
) error

ExecuteTasksCore coordinates parallel task execution with concurrency limit, timeout, and fail-fast.

func ExitCodeFrom

func ExitCodeFrom(err error) int

ExitCodeFrom extracts the OS exit code from err.

  • nil → 0
  • *exec.ExitError → the process exit code
  • any other error → 1

func RelPath

func RelPath(reposRoot, repoAbsPath string) string

RelPath returns repoAbsPath relative to reposRoot. Falls back to repoAbsPath when reposRoot is empty or the computation fails.

Types

type FileResult

type FileResult struct {
	RepoAbsPath string `json:"repo_abs_path"` // absolute path of the repository
	RepoRelPath string `json:"repo_rel_path"` // path relative to repos root
	FileRelPath string `json:"file_rel_path"` // file path relative to repository
	FileAbsPath string `json:"file_abs_path"` // absolute path of the file
}

FileResult is the JSON representation for subcommands that list files across repositories (e.g. "ls-files").

type RepoResult

type RepoResult struct {
	RepoAbsPath string `json:"repo_abs_path"` // absolute path of the repository
	RepoRelPath string `json:"repo_rel_path"` // path relative to repos root
}

RepoResult is the JSON representation for subcommands that list repositories without running a command (e.g. "list").

type Result

type Result struct {
	RepoAbsPath string   `json:"repo_abs_path"` // absolute path of the repository
	RepoRelPath string   `json:"repo_rel_path"` // path relative to repos root
	Command     []string `json:"command"`       // command that was executed
	ExitCode    int      `json:"exit_code"`     // OS exit code (0 = success)
	Stdout      string   `json:"stdout"`        // captured standard output
	Stderr      string   `json:"stderr"`        // captured standard error
}

Result holds the outcome of running a single command in one repository. It is serialised as one JSON object per line in json output mode.

func ExecuteTask

func ExecuteTask(ctx context.Context, task Task, timeout time.Duration, failFast bool) (Result, error)

ExecuteTask runs a single task, emitting logs and returning the Result and error.

type Task

type Task struct {
	// RepoAbsPath is the absolute path of the repository.
	RepoAbsPath string
	// ReposRoot is used to compute RepoRelPath; may be empty.
	ReposRoot string
	// Dir is the working directory passed to Runner (usually equals RepoAbsPath).
	Dir string
	// Command is the argv slice to execute.
	Command []string
	// Runner executes the command. If nil, runner.ProcessRunner{} is used.
	Runner runner.Runner
}

Task describes a single unit of work for Executors. Each Task carries its own Runner so callers can inject per-repo runners (e.g. a GrepRunner configured for a specific repository).

type WorktreeResult added in v0.4.0

type WorktreeResult struct {
	WorktreeAbsPath string `json:"worktree_abs_path"` // absolute path of the worktree
	WorktreeRelPath string `json:"worktree_rel_path"` // worktree path relative to worktree root
	RepoAbsPath     string `json:"repo_abs_path"`     // absolute path of the main repository
	RepoRelPath     string `json:"repo_rel_path"`     // main repository path relative to repos root
	Branch          string `json:"branch"`            // branch checked out in the worktree
}

WorktreeResult is the JSON representation for subcommands that list or manage git worktrees (e.g. "worktree list").

Jump to

Keyboard shortcuts

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