Documentation
¶
Index ¶
Constants ¶
const ( EXIT_SUCCESS = 0 EXIT_FAILURE = 1 )
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute runs the provided cobra.Command using the given context. Disables the cobra facilities for top-level error reporting. It returns an exit code based on the command execution result:
- EXIT_SUCCESS if the command executes without error
- The code from ErrSilentExit if that error is returned
- EXIT_FAILURE for all other errors, after logging them either with the zap logger from the context or fmt as a fallback
func SignalContext ¶
SignalContext returns a context that is canceled when a termination signal is received. It listens for SIGTERM and SIGINT. On the first signal, the context is canceled with an error describing the signal. If a second signal is received, the process exits immediately. This allows for graceful shutdown on the first signal and forced termination on the second.
Types ¶
type ErrSilentExit ¶
type ErrSilentExit struct {
Code int // Code is the exit code to be used when exiting.
}
ErrSilentExit represents an error that causes the application to exit silently with a specific exit code.
func (*ErrSilentExit) Error ¶
func (e *ErrSilentExit) Error() string
Error implements the error interface for ErrSilentExit. It returns a formatted string containing the exit code.