var _exit … // With terminates the process by calling os.Exit(code). If the package is // stubbed, it instead records a call in the testing spy. func With(code int) { … } type StubbedExit … // Stub substitutes a fake for the call to os.Exit(1). func Stub() *StubbedExit { … } // WithStub runs the supplied function with Exit stubbed. It returns the stub // used, so that users can test whether the process would have crashed. func WithStub(f func()) *StubbedExit { … } // Unstub restores the previous exit function. func (se *StubbedExit) Unstub() { … } func (se *StubbedExit) exit(code int) { … }