Documentation
¶
Overview ¶
Package process holds the parts of a binary's main sequence that run before the program's own infrastructure exists: reporting a failure or a usage error when there is no logger yet, the signal-derived root context, and the exit-code convention the reporters return. An application's entrypoint, the minimal binary above its composition root, composes its run function from it, so the convention cannot drift between a program's binaries.
The package exports:
- ExitOK, ExitFailure, and ExitUsage, the exit codes
- Fail, which reports a runtime failure and returns ExitFailure
- Usage, which reports a usage error or help and returns ExitUsage
- SignalContext, which returns the root context SIGINT or SIGTERM cancels
Index ¶
Constants ¶
const ( ExitOK = 0 ExitFailure = 1 ExitUsage = 2 )
Exit codes shared by a program's binaries: 0 ok, 1 runtime failure, 2 usage error.
Variables ¶
This section is empty.
Functions ¶
func SignalContext ¶
func SignalContext() (context.Context, context.CancelFunc)
SignalContext returns a context cancelled on SIGINT or SIGTERM, and the stop function that releases the signal registration. Call stop once the context is done, so a second signal terminates the process at once.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package processtest is the integration toolkit for a program built on the process package.
|
Package processtest is the integration toolkit for a program built on the process package. |
|
internal/testprog
command
Command testprog is the program the processtest package's own tests run: it answers on a loopback address, waits for the interrupt, and exits with the code its environment names, so the runner is proved against a real subprocess without a service behind it.
|
Command testprog is the program the processtest package's own tests run: it answers on a loopback address, waits for the interrupt, and exits with the code its environment names, so the runner is proved against a real subprocess without a service behind it. |