go-cli-process-control
Execute and supervise external programs safely from Go CLIs with explicit arguments, typed failure classification, working directories, environments…
它会碰到什么
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Go CLI Process Control
Treat child-process lifecycle as correctness. Observe the terminal result,
propagate cancellation, and clean up every process, pipe, and temporary resource.
Core Workflow
- Define the child executable, argv, environment, directory, streams, and success contract.
- Use an explicit shell only when shell semantics are actually required.
- Inject a runner boundary and propagate the caller's context.
- Observe startup and completion; preserve status and useful redacted stderr.
- Bound captured output, cancellation, and shutdown time.
- Account for descendants and wait for every pipeline stage.
- Test missing tools, bad exits, malformed output, cancellation, signals, and cleanup.
Read Next
| Task | Load |
|---|---|
| Implement or repair process supervision | guidelines.md, workflows/supervise-external-command.md |
| Apply modern execution and cancellation rules | references/process-control/rules.md |
| Use runner, pipeline, signal, or cleanup patterns | references/process-control/patterns.md |
| Start from focused code examples | references/process-control/examples.md |
| Review a subprocess boundary | references/process-control/checklist.md |
| Understand lifecycle and shell semantics | references/process-control/knowledge.md |
Guardrails
- Pass executable arguments separately; never assume
exec.Commandinvokes a shell. - Do not treat
Startas success; inspect the terminal result. - Do not assume context cancellation terminates an entire process tree.
- Close owned pipes and wait for every started process.
- Distinguish lookup, start, exit, timeout, cancellation, and cleanup failures.
- Treat
Cmd.String()as diagnostic text, never shell-safe replay or secret-safe output. - Avoid mutable package-level command hooks in concurrent tests.
Source Notes
Guidance is transformed and paraphrased from Ricardo Gerardi,
Powerful Command-Line Applications in Go (Pragmatic Bookshelf, 2021),
especially Chapter 6. Examples are original adaptations.
Book: https://pragprog.com/titles/rggo/powerful-command-line-applications-in-go/
Verify current behavior against https://pkg.go.dev/os/exec and
https://pkg.go.dev/os/signal, including Cmd.Cancel, WaitDelay, and
signal.NotifyContext.
Failure taxonomy, pipe ordering, and platform-adapter guidance also incorporates
transformed material from Marian Montagnino, *Building Modern CLI Applications
in Go* (Packt, 2023), especially Chapter 6.
In-process cancellation boundary guidance also incorporates transformed
material from Inanc Gumus, *Go by Example: Programmer's Guide to Idiomatic and
Testable Programs* (Manning, 2025), Chapters 6-7.
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
plugins/LVTD-LLC/skills/skills/go-cli-process-control/SKILL.md